The jasperPrint
object has portrait orientation, but jasperPrint2
object has landscape orientation. I want to combine the two jasperprints to produ
You can accomplish this by doing a batch export.
//put all the jasperPrints you want to be combined into a pdf in this list
List jasperPrintList = new ArrayList();
JasperReport report = (JasperReport) JRLoader.loadObject(reportFile2.getPath());
jasperPrintList.add(JasperFillManager.fillReport(report, parameters, conn));
JasperReport report2 = (JasperReport) JRLoader.loadObject(reportFile.getPath());
jasperPrintList.add(JasperFillManager.fillReport(report2, parameters, conn));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JRPdfExporter exporter = new JRPdfExporter();
//this sets the list of jasperPrint objects to be exported and merged
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
//the bookmarks is a neat extra that creates a bookmark for each jasper print
exporter.setParameter(JRPdfExporterParameter.IS_CREATING_BATCH_MODE_BOOKMARKS, Boolean.TRUE);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
exporter.exportReport();
return baos.toByteArray();