public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { res.setContentType("text/xml"); res.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\""); JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); //exporter.setParameter(JRExporterParameter.START_PAGE_INDEX, Integer.valueOf(1)); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
/** * @param jp * @return * @throws JazzOMRJRException * @throws JRException */ protected byte[] exportToXML(JasperPrint jp) throws JazzOMRJRException { ByteArrayOutputStream baosXML = new ByteArrayOutputStream(); JRXmlExporter exporter = new JRXmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML); exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE); try { exporter.exportReport(); } catch (JRException e1) { throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e1); } byte[] xmlBytes = null; try { baosXML.flush(); xmlBytes = baosXML.toByteArray(); baosXML.close(); } catch (IOException e) { throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e); } return xmlBytes; }
/** * @param jp * @return * @throws JazzOMRJRException * @throws JRException */ private byte[] exportToXML(JasperPrint jp) { ByteArrayOutputStream baosXML = new ByteArrayOutputStream(); JRXmlExporter exporter = new JRXmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML); exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE); try { exporter.exportReport(); } catch (JRException e1) { throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e1); } byte[] xmlBytes = null; try { baosXML.flush(); xmlBytes = baosXML.toByteArray(); baosXML.close(); } catch (IOException e) { throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e); } return xmlBytes; }
/** * @param jp * @return * @throws JazzOMRJRException * @throws JRException */ private byte[] exportToXML(JasperPrint jp) { ByteArrayOutputStream baosXML = new ByteArrayOutputStream(); JRXmlExporter exporter = new JRXmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML); exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE); try { exporter.exportReport(); } catch (JRException e1) { throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1); } byte[] xmlBytes = null; try { baosXML.flush(); xmlBytes = baosXML.toByteArray(); baosXML.close(); } catch (IOException e) { throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e); } return xmlBytes; }
/** * @param jp * @return * @throws JazzOMRJRException * @throws JRException */ protected byte[] exportToXML(JasperPrint jp) { ByteArrayOutputStream baosXML = new ByteArrayOutputStream(); JRXmlExporter exporter = new JRXmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML); exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE); try { exporter.exportReport(); } catch (JRException e1) { throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1); } byte[] xmlBytes = null; try { baosXML.flush(); xmlBytes = baosXML.toByteArray(); baosXML.close(); } catch (IOException e) { throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e); } return xmlBytes; }
/** * Exports the generated report object received as parameter into XML format, * placing the result into the second file parameter. * <p> * If not embedded into the XML content itself using the Base64 encoder, * the images are placed as distinct files inside a directory having the same name * as the XML destination file, plus the "_files" suffix. * * @param jasperPrint report object to export * @param destFileName file name to place the XML representation into * @param isEmbeddingImages flag that indicates whether the images should be embedded in the * XML content itself using the Base64 encoder or be referenced as external resources * * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public void exportToXmlFile( JasperPrint jasperPrint, String destFileName, boolean isEmbeddingImages ) throws JRException { JRXmlExporter exporter = new JRXmlExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleXmlExporterOutput xmlOutput = new SimpleXmlExporterOutput(destFileName); xmlOutput.setEmbeddingImages(isEmbeddingImages); exporter.setExporterOutput(xmlOutput); exporter.exportReport(); }
/** * Outputs the XML representation of a value if the value is supported by any handler. * * @param value the value * @param exporter the exporter * @return <code>true</code> iff a handler that supports the value was found * @throws IOException * @see XmlValueHandler#writeToXml(Object, JRXmlExporter) */ public boolean writeToXml(Object value, JRXmlExporter exporter) throws IOException { for (XmlValueHandler handler : getHandlers()) { if (handler.writeToXml(value, exporter)) { if (log.isDebugEnabled()) { log.debug("Handler " + handler + " wrote value " + value); } return true; } } if (log.isDebugEnabled()) { log.debug("No handler wrote value " + value); } return false; }
@Override protected void initReport() { super.initReport(); if(jasperPrint.hasProperties() && jasperPrint.getPropertiesMap().containsProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS)) { // allows null values for the property invalidCharReplacement = jasperPrint.getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS); } else { invalidCharReplacement = getPropertiesUtil().getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS, jasperPrint); } nature = new JROdtExporterNature(getJasperReportsContext(), filter); }
@Override protected void initReport() { super.initReport(); if (jasperPrint.hasProperties() && jasperPrint.getPropertiesMap().containsProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS)) { // allows null values for the property invalidCharReplacement = jasperPrint.getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS); } else { invalidCharReplacement = getPropertiesUtil().getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS, jasperPrint); } renderersCache = new RenderersCache(getJasperReportsContext()); }
@Override protected void initReport() { super.initReport(); if (jasperPrint.hasProperties() && jasperPrint.getPropertiesMap().containsProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS)) { // allows null values for the property invalidCharReplacement = jasperPrint.getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS); } else { invalidCharReplacement = getPropertiesUtil().getProperty(JRXmlExporter.PROPERTY_REPLACE_INVALID_CHARS, jasperPrint); } DocxReportConfiguration configuration = getCurrentItemConfiguration(); nature = new JRDocxExporterNature( jasperReportsContext, filter, !configuration.isFramesAsNestedTables() ); renderersCache = new RenderersCache(getJasperReportsContext()); }
@Override public void exportElement( JRXmlExporterContext exporterContext, JRGenericPrintElement element ) { try { JRXmlExporter exporter = (JRXmlExporter)exporterContext.getExporterRef(); exporter.exportImage(MapElementImageProvider.getImage(exporterContext.getJasperReportsContext(), element)); } catch (Exception e) { throw new RuntimeException(e); } }
protected String elementToXml(JRPrintElement element) { JRBasePrintPage page = new JRBasePrintPage(); page.addElement(element); JasperPrint jasperPrint = new JasperPrint(); jasperPrint.addPage(page); jasperPrint.setName("test"); StringWriter writer = new StringWriter(); JRXmlExporter exporter = new JRXmlExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleXmlExporterOutput output = new SimpleXmlExporterOutput(writer); output.setEmbeddingImages(true); exporter.setExporterOutput(output); try { exporter.exportReport(); } catch (JRException e) { throw new RuntimeException(e); } return writer.toString(); }
public ByteArrayOutputStream generateXmlReport(JasperPrint jasperPrint) throws JRException, ReportingException { ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream(); if(jasperPrint==null){ throw new ReportingException("jasperPrint null, can't convert to XML report"); } JRXmlExporter jrXmlExporter = new JRXmlExporter(); jrXmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); jrXmlExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xmlOutputStream); try { jrXmlExporter.exportReport(); } catch (JRException e) { throw new JRException("Error occurred exporting PDF report ", e); } return xmlOutputStream; }
public static byte[] getXml(JasperPrint jasperPrint) throws JRException { byte[] content = null; ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); JRXmlExporter exporter = new JRXmlExporter(); content = getBytes(exporter, baos, jasperPrint); } finally { if (baos != null) { try { baos.flush(); baos.close(); } catch (Exception e) { e.printStackTrace(); } } } return content; }
@Override public void save(JasperPrint jasperPrint, File file) throws JRException { if ( !file.getName().toLowerCase().endsWith(EXTENSION_XML) && !file.getName().toLowerCase().endsWith(EXTENSION_JRPXML) ) { file = new File(file.getAbsolutePath() + EXTENSION_JRPXML); } if ( !file.exists() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( null, MessageFormat.format( getBundleString("file.exists"), new Object[]{file.getName()} ), getBundleString("save"), JOptionPane.OK_CANCEL_OPTION ) ) { JRXmlExporter exporter = new JRXmlExporter(getJasperReportsContext()); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleXmlExporterOutput output = new SimpleXmlExporterOutput(file); output.setEmbeddingImages(true); exporter.setExporterOutput(output); exporter.exportReport(); } }
@Override public void save(JasperPrint jasperPrint, File file) throws JRException { if ( !file.getName().toLowerCase().endsWith(EXTENSION_XML) && !file.getName().toLowerCase().endsWith(EXTENSION_JRPXML) ) { file = new File(file.getAbsolutePath() + EXTENSION_JRPXML); } if ( !file.exists() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( null, MessageFormat.format( getBundleString("file.exists"), new Object[]{file.getName()} ), getBundleString("save"), JOptionPane.OK_CANCEL_OPTION ) ) { JRXmlExporter exporter = new JRXmlExporter(getJasperReportsContext()); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleXmlExporterOutput output = new SimpleXmlExporterOutput(file); output.setEmbeddingImages(false); exporter.setExporterOutput(output); exporter.exportReport(); } }
/** * Exports the generated report object supplied as the first parameter into XML format, * and writes the result to the output stream specified by the second parameter. * The images are embedded into the XML content itself using the Base64 encoder. * * @param jasperPrint report object to export * @param outputStream output stream to write the resulting XML representation to * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public void exportToXmlStream( JasperPrint jasperPrint, OutputStream outputStream ) throws JRException { JRXmlExporter exporter = new JRXmlExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleXmlExporterOutput(outputStream)); exporter.exportReport(); }
/** * Exports the generated report object supplied as parameter into XML format * and returs the result as String. * The images are embedded into the XML content itself using the Base64 encoder. * * @param jasperPrint report object to export * @return XML representation of the generated report * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public String exportToXml(JasperPrint jasperPrint) throws JRException { StringBuilder sb = new StringBuilder(); JRXmlExporter exporter = new JRXmlExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleXmlExporterOutput(sb)); exporter.exportReport(); return sb.toString(); }
protected void xmlExport(JasperPrint print, OutputStream out) throws JRException, IOException { JRXmlExporter exporter = new JRXmlExporter(); exporter.setExporterInput(new SimpleExporterInput(print)); SimpleXmlExporterOutput output = new SimpleXmlExporterOutput(out); output.setEmbeddingImages(true); exporter.setExporterOutput(output); exporter.exportReport(); out.close(); }
@Override protected JRXmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXmlExporter exp = new JRXmlExporter(jContext); SimpleXmlExporterOutput expOut = new SimpleXmlExporterOutput(file); expOut.setEmbeddingImages(Boolean.TRUE); exp.setExporterOutput(expOut); SimpleReportExportConfiguration rconf = new SimpleReportExportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXmlExporter exp = new JRXmlExporter(jContext); SimpleXmlExporterOutput expOut = new SimpleXmlExporterOutput(file); expOut.setEmbeddingImages(Boolean.FALSE); exp.setExporterOutput(expOut); SimpleReportExportConfiguration rconf = new SimpleReportExportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
private JRXmlExporter xml(JasperIXmlExporter jasperExporter) { SimpleXmlExporterOutput exporterOutput = simpleXmlExporterOutput(jasperExporter); if (jasperExporter.getEmbeddingImages() != null) { exporterOutput.setEmbeddingImages(jasperExporter.getEmbeddingImages()); } SimpleReportExportConfiguration reportExportConfiguration = new SimpleReportExportConfiguration(); reportExportConfiguration(reportExportConfiguration, jasperExporter); SimpleExporterConfiguration exporterConfiguration = new SimpleExporterConfiguration(); JRXmlExporter jrExporter = new JRXmlExporter(); jrExporter.setExporterOutput(exporterOutput); jrExporter.setConfiguration(reportExportConfiguration); jrExporter.setConfiguration(exporterConfiguration); return jrExporter; }
@Override public void exportElement(JRXmlExporterContext exporterContext, JRGenericPrintElement element) { try { JRXmlExporter exporter = (JRXmlExporter) exporterContext.getExporter(); exporter.exportImage(getImage(exporterContext.getJasperReportsContext(), element)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * */ public void xml() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/TextReport.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".jrpxml"); JRXmlExporter exporter = new JRXmlExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleXmlExporterOutput(destFile)); exporter.exportReport(); System.err.println("XML creation time : " + (System.currentTimeMillis() - start)); }
@Override public JRXmlExporter getExporter() { return new JRXml4SwfExporter(DefaultJasperReportsContext.getInstance()); }
/** * */ public JRXmlExporter getExporter() { return new JRXmlExporter(DefaultJasperReportsContext.getInstance()); }
/** * Exporta bullet para alternativa de questao * @param exporterContext * @param element * @param eqaKey */ protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) { int x = element.getX() + exporterContext.getOffsetX(); int y = element.getY() - exporterContext.getOffsetY(); int x2 = x + element.getWidth(); int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight(); int w = x2 - x; int h = y - y2; JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter(); JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider(); if (log.isDebugEnabled()) { log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + ""); } JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider); //darcio 25/06/2013 nao sera mais necessario marcar a p�gina por aqui //Object actualPage = element.getParameterValue("actualPage"); //ellipse.setKey("" + eqaKey + "-" + actualPage); ellipse.setKey("" + eqaKey); ellipse.setX(x); ellipse.setY(y); ellipse.setHeight(h); ellipse.setWidth(w); JRPrintText text = new JRBasePrintText(defaultStyleProvider); text.setForecolor(Color.RED); text.setX(x + 20); text.setY(y + 3); text.setHeight(10); text.setWidth(200); text.setText(eqaKey + " x=" + x + " y=" + y); try { xmlExporter.exportElement(ellipse); xmlExporter.exportText(text); } catch (Exception e) { throw new RuntimeException("Erro ao tentar exportar elemento", e); } }
/** * Exporta bullet para alternativa de questao * @param exporterContext * @param element * @param eqaKey */ protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) { int x = element.getX() + exporterContext.getOffsetX(); int y = element.getY() - exporterContext.getOffsetY(); int x2 = x + element.getWidth(); int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight(); int w = x2 - x; int h = y - y2; JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter(); JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider(); if (log.isDebugEnabled()) { log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + ""); } JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider); Object actualPage = element.getParameterValue("actualPage"); ellipse.setKey("" + eqaKey + "-" + actualPage); ellipse.setX(x); ellipse.setY(y); ellipse.setHeight(h); ellipse.setWidth(w); JRPrintText text = new JRBasePrintText(defaultStyleProvider); text.setForecolor(Color.RED); text.setX(x + 20); text.setY(y + 3); text.setHeight(10); text.setWidth(200); text.setText(eqaKey + " x=" + x + " y=" + y); try { xmlExporter.exportElement(ellipse); xmlExporter.exportText(text); } catch (Exception e) { throw new RuntimeException("Erro ao tentar exportar elemento", e); } }
public void exportToXml() { download(getFileName() + ".xml", new JRXmlExporter()); }