/** * Export to PNG * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception * @throws IOException IOException exception */ public SpecificTemplateExporterBuilderService toPng() throws JRException, IOException { BufferedImage pageImage = new BufferedImage(this.report.getPageWidth() + 1, this.report.getPageHeight() + 1, BufferedImage.TYPE_INT_RGB); JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setExporterInput(new SimpleExporterInput(this.report)); SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); exporter.setExporterOutput(exporterOutput); exporter.exportReport(); ImageIO.write(pageImage, "png", new FileOutputStream(new File(getTemplatePath().replace(extensionPattern, "png")))); return this; }
try { SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint); SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); Image pageImage = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_RGB); exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); SimpleGraphics2DReportConfiguration reportExportConfiguration = new SimpleGraphics2DReportConfiguration(); reportExportConfiguration.setPageIndex(i);
try { SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint); SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); Image pageImage = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_RGB); exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); SimpleGraphics2DReportConfiguration reportExportConfiguration = new SimpleGraphics2DReportConfiguration(); reportExportConfiguration.setPageIndex(fromPage);