Jump to content
JasperReports 7.0 is now available ×

How to export print list of two documents as byte array?


Recommended Posts


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 sexporter.setExporterOutput(new SimpleOutputStreamExporterOutput(System.getProperty("user.home") + "/output.pdf")); //or any other out streaamSimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();configuration.setCreatingBatchModeBookmarks(true); //add this so your bookmarks work, you may set other parametersexporter.setConfiguration(configuration);exporter.exportReport();[/code]

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...

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...