cool3690 Posted December 14, 2018 Share Posted December 14, 2018 I have a problem I want to download PDF automaticallyI also have data input and show on web is okbut when my pdf download ,it always blankwhy?<% String Lang3=""; Object sql1=session.getAttribute("Lang2"); if(sql1!=null){Lang3=sql1.toString();}//sql data ResultSet rs = stmt.executeQuery(Lang3); File reportFile = new File(application.getRealPath("/report/report3.jasper")); File reportFile2 = new File(application.getRealPath("/report/report3.jrxml")); Map parameters = new HashMap(); JRDataSource dataSource = new JRResultSetDataSource(rs); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, dataSource); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outStream = response.getOutputStream(); JasperPrint print = JasperFillManager.fillReport(reportFile.toString(), parameters, dataSource); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outStream); response.setHeader("Content-Disposition", "attachment;filename=" + "a" + ".pdf"); exporter.exportReport(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); rs.close();%>[/code]thanks Link to comment Share on other sites More sharing options...
vchiem Posted December 17, 2018 Share Posted December 17, 2018 Maybe its font related where the font is not available to PDF export. Check these sections on how to embed fonts in PDF. Studio User guide: CHAPTER 9 FONTSServer Admin guide: 5.7.1 Fonts"when exporting the report to PDF, you may need to take additional steps if the report includes fonts" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now