How to merge two pdf documents into a single report in JasperReports?

前端 未结 5 1780
无人共我
无人共我 2020-12-15 00:38

I am new to JasperReports. I can create a simple PDF document with Javabean datasource. In my project I have created two separate pdf document with separate javabean datasou

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 01:07

    You can use use a list of JasperPrint like this:

    List jasperPrintList = new ArrayList();
    
    jasperPrintList.add(JasperFillManager.fillReport("Report_file1.jasper", getReportMap(1), new JREmptyDataSource()));
    jasperPrintList.add(JasperFillManager.fillReport("Report_file2.jasper", getReportMap(2), new JREmptyDataSource()));
    jasperPrintList.add(JasperFillManager.fillReport("Report_file3.jasper", getReportMap(3), new JREmptyDataSource()));
    
    JRPdfExporter exporter = new JRPdfExporter();
    
    exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("Report_PDF.pdf"));
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    configuration.setCreatingBatchModeBookmarks(true);
    exporter.setConfiguration(configuration);
    
    exporter.exportReport();
    

提交回复
热议问题