Reputation: 86935
I'm creating PDF
reports with JasperReports
as follows:
JasperExportManager.exportReportToPdf(jasperPrint)
Now I'd also like to generate a HTML
text stream. How could I achieve this without having to write that generated file to local disc?
I want to send the generated html as email body.
Upvotes: 1
Views: 4790
Reputation: 1426
Instead of using JasperExportManager
, you could use JRHtmlExporter
. Try something like this:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setExporterInput(new SimpleExporterInput(yourJasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos));
exporter.exportReport();
After exportReport
is called, the ByteArrayOutputStream
will contain your HTML.
Upvotes: 1