I am trying to introduce HTML export to our JasperReports based reporting engine. An HTML document is generated perfectly, but problems begin when it contains images. Images are not part of HTML, unlike PDF.
The solution I have found so far is the following:
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, "./images/");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/images/");
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
Thus, all images are automatically generated by JasperReports and saved in this "images" folder. They also reference the HTML file correctly.
, , HTML-, . , , , JasperReports .
JasperReports, - ?