To export a you need to fill the report to get the JasperPrint object.
// 1. Create exporter instance
JRPdfExporter exporter = new JRPdfExporter();
// 2. Set exporter input document
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
// 3. Set file path for exporter output
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
// 4. Create configuration instance
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
// 5. Associate configuration with exporter
exporter.setConfiguration(configuration);
// 6. Fill export and write to file path
exporter.exportReport();
Only the first steps differ from the previous set:
List<JasperPrint> jasperPrintList = new ArrayList<>();
jasperPrintList.add(jasperPrint1);
jasperPrintList.add(jasperPrint2);
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
The remaining steps are the same:
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();
See SimplePdfExporterConfiguration API for configuration details.