@Override protected JRXhtmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXhtmlExporter exp = new JRXhtmlExporter(jContext); exp.setExporterOutput(new SimpleHtmlExporterOutput(file)); SimpleHtmlReportConfiguration rconf = new SimpleHtmlReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
/** * Exports by MIME type. * * @param mimeType MIME type * @param jp Jasper print * @param os outputstream * @throws JRException */ protected void export(String mimeType, JasperPrint jp, OutputStream os) throws JRException { if ("application/pdf".equalsIgnoreCase(mimeType)) { exportReport(new JRPdfExporter(), jp, os); } else if ("text/xml".equalsIgnoreCase(mimeType)) { exportReport(new HtmlExporter(), jp, os); } else if ("application/rtf".equalsIgnoreCase(mimeType)) { exportReport(new JRRtfExporter(), jp, os); } else if ("application/xls".equalsIgnoreCase(mimeType)) { exportReport(new JRXlsExporter(), jp, os); } else if ("application/odt".equalsIgnoreCase(mimeType)) { exportReport(new JROdtExporter(), jp, os); } else if ("application/ods".equalsIgnoreCase(mimeType)) { exportReport(new JROdsExporter(), jp, os); } else if ("application/docx".equalsIgnoreCase(mimeType)) { exportReport(new JRDocxExporter(), jp, os); } else if ("application/xlsx".equalsIgnoreCase(mimeType)) { exportReport(new JRXlsxExporter(), jp, os); } else if ("application/pptx".equalsIgnoreCase(mimeType)) { exportReport(new JRPptxExporter(), jp, os); } else if ("text/xhmtl".equalsIgnoreCase(mimeType)) { exportReport(new JRXhtmlExporter(), jp, os); } else { throw new IllegalArgumentException("JasperRenderer does not support " + mimeType + " MIME type."); } }
@Override public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element) { Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode()); if (context.getExporter() instanceof JRXhtmlExporter) { contextMap.put("xhtml", "xhtml"); JRXhtmlExporter xhtmlExporter = (JRXhtmlExporter) context.getExporter(); contextMap.put("elementX", xhtmlExporter.toSizeUnit(element.getX())); contextMap.put("elementY", xhtmlExporter.toSizeUnit(element.getY())); } else { JRHtmlExporter htmlExporter = (JRHtmlExporter) context.getExporter(); contextMap.put("elementX", htmlExporter.toSizeUnit(element.getX())); contextMap.put("elementY", htmlExporter.toSizeUnit(element.getY())); } contextMap.put("elementId", element.getKey()); contextMap.put("elementWidth", element.getWidth()); contextMap.put("elementHeight", element.getHeight()); if (element.getModeValue() == ModeEnum.OPAQUE) { contextMap.put("backgroundColor", JRColorUtil.getColorHexa(element.getBackcolor())); } WmsRequestBuilder requestBuilder = WmsMapElementImageProvider.mapRequestBuilder(element); try { contextMap.put("wmsMapUrl", requestBuilder.toMapUrl()); } catch (MalformedURLException e) { throw new RuntimeException("Unable to build WMS map service url", e); } return VelocityUtil.processTemplate(MAP_ELEMENT_HTML_TEMPLATE, contextMap); }
/** * */ public void xhtml() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/ScriptletReport.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".x.html"); JRXhtmlExporter exporter = new JRXhtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); System.err.println("XHTML creation time : " + (System.currentTimeMillis() - start)); }
/** * */ public void xhtml() throws JRException { long start = System.currentTimeMillis(); File destFile = new File("target/reports/RrdGraph.x.html"); JRXhtmlExporter exporter = new JRXhtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, m_jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); System.err.println("XHTML creation time : " + (System.currentTimeMillis() - start)); }
public void exportToHtml() { download(getFileName() + ".html", new JRXhtmlExporter()); }
@Override public GenericElementHandler getHandler(String elementName, String exporterKey) { if (WmsMapPrintElement.WMS_MAP_ELEMENT_NAME.equals(elementName)) { if (JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY .equals(exporterKey)) { return WmsMapElementGraphics2DHandler.getInstance(); } if (JRHtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey) || JRXhtmlExporter.XHTML_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementHtmlHandler.getInstance(); } else if (JRPdfExporter.PDF_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementPdfHandler.getInstance(); } else if (JRXlsExporter.XLS_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementXlsHandler.getInstance(); } else if (JExcelApiExporter.JXL_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementJExcelApiHandler.getInstance(); } // else // if(JExcelApiMetadataExporter.JXL_METADATA_EXPORTER_KEY.equals(exporterKey)) // { // return MapElementJExcelApiMetadataHandler.getInstance(); // } else if (JRXlsxExporter.XLSX_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementXlsxHandler.getInstance(); } else if (JRDocxExporter.DOCX_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementDocxHandler.getInstance(); } else if (JRPptxExporter.PPTX_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementPptxHandler.getInstance(); } else if (JRRtfExporter.RTF_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementRtfHandler.getInstance(); } else if (JROdtExporter.ODT_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementOdtHandler.getInstance(); } else if (JROdsExporter.ODS_EXPORTER_KEY.equals(exporterKey)) { return WmsMapElementOdsHandler.getInstance(); } } return null; }
private void xhtml() throws JRException { File destFile = new File("target/reports/ResourceTypeTest.x.html"); JRXhtmlExporter exporter = new JRXhtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, m_jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); }