2022-04-14

Multiple JasperPrint into a pdf with output as file and byte[]

 Multiple JasperPrint into a pdf with output as file and byte[]

JasperExportManager.exportReportToPdf vs JRPdfExporter.exportReport()








Found: https://community.jaspersoft.com/questions/526021/how-merge-multiple-pdf-jasper-reports-one







Multiple JasperPrint into a file
setCreatingBatchModeBookmarks

public void pdf() throws JRException { long start = System.currentTimeMillis(); List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>(); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint")); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BatchExportReport.pdf")); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }



JRPdfExporter to byte array

Found: https://www.tabnine.com/code/java/methods/net.sf.jasperreports.engine.export.JRPdfExporter/setParameter

public byte[] exportToPdf(JasperPrint jasperPrint) throws JRException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); exporter.exportReport(); return baos.toByteArray(); }




more Java JRPdfExporter.exportReport方法代碼示例
Found: https://vimsky.com/zh-tw/examples/detail/java-method-net.sf.jasperreports.engine.export.JRPdfExporter.exportReport.html


示例1: export
示例2: savePDFReportToOutputStream
示例3: concatPDFReport
示例4: concatPDFReportEncrypted


Billson: file
示例5: pdf























No comments:

Google Referrals