How to collate multiple jrxml jasper reports into a one single pdf output file

后端 未结 5 677
一个人的身影
一个人的身影 2020-11-30 08:06

I have to prepare reports using five different sql queries. Each query will give out one report table.

So I wrote 5 jrxml files each corresponding to one of the abov

5条回答
  •  抹茶落季
    2020-11-30 08:27

    This answer is to help users with JASPER REPORT VERSION >5.6 (latest versions), hence remove the deprecated code.

    Since jasper-report 5.6 JRPdfExporterParameter.JASPER_PRINT_LIST is deprecated the current code of Wojtek Owczarczyk answer is:

    List jpList = new ArrayList<>();
    //add your JasperPrint's from loading jrprint or more 
    //commonly filling report with JasperFillManager.fillReport 
    
    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setExporterInput(SimpleExporterInput.getInstance(jpList)); //Set as export input
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(stream)); //Set output stream
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    //set your configuration
    exporter.setConfiguration(configuration);
    exporter.exportReport();
    

提交回复
热议问题