Hi,
I have a code like this:
mainReport = JasperFillManager.fillReport(report, invoiceMap, new JREmptyDataSource()); tableReport = JasperFillManager.fillReport(table, taskListMap, new JREmptyDataSource()); List<JasperPrint> printList = new ArrayList<>(); printList.add(mainReport); printList.add(tableReport); JRPdfExporter exporter = new JRPdfExporter(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); exporter.setExporterInput(SimpleExporterInput.getInstance(printList)); //Set as export input my list with JasperPrint s exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(System.getProperty("user.home") + "/output.pdf")); //or any other out streaam SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); //add this so your bookmarks work, you may set other parameters exporter.setConfiguration(configuration); exporter.exportReport();
But it is exporting the report to a file. I need to change this code so it is returning a byte[] so I can make an rest service endpoint to download the file... But I don't seem to find a method to do this...
1 Answer:
Posted on March 27, 2019 at 1:58am
Have you tried exporting to ByteArrayOutputStream using export.exportReportToStream() and then converting it to .toByteArray()?
http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/exp...
is there any way to sort the printList?