开发者

How to export a JasperReport to HTML, without saving the images on a disk?

I'm trying to introduce a HTML export to our JasperReports based report engine. The HTML document is generated fine, but the problems start when it contains images. The images are not pa开发者_C百科rt of the HTML in contrast with PDF.

The solution I 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();

This way all the images are automatically generated by JasperReports and saved in this "images" folder. They are also correctly referenced by the HTML file.

The problem is that the images are saved too late in the folder and the user needs to refresh the already received HTML page in order to see them. This is really not nice and also I don't see why the images should be saved, since they are automatically generated by JasperReports anyway.

How can I tell JasperReports to store the images in memory somehow and how the user will access them in this case?


Check the Jasper examples (part of the source distribution), it has a 'webapp' example that shows how you can use an image servlet for that end.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜