1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
response.setContentType("text/html");
response.setHeader("Content-disposition", "filename="+realName+".html");
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, servletOutputStream);
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER,out);
HashMap<Object, Object> fontMap = new HashMap<Object, Object>();
Map<String, Object> imagesMap = new HashMap<String, Object>();
imagesMap.put("logo.jpg", getServletContext().getRealPath("/report/jasper/image/logo.jpg"));
request.getSession().setAttribute("IMAGES_MAP",imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"/report/jasper/image?image=");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,getServletContext().getRealPath("/report/jasper/image"));
exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,Boolean.TRUE);
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, "px");
exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.FONT_MAP, fontMap);
exporter.exportReport();
servletOutputStream.flush();
servletOutputStream.close(); |
Partager