Jump to content
Changes to the Jaspersoft community edition download ×

jasperreport pdf auto download but empty


Recommended Posts

I have a problem 

I want to download PDF automatically

I also have data input and show on web is ok

but when my pdf download ,it always blank


<%       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]


Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 FONTS

Server 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...