ranG Posted August 18, 2006 Share Posted August 18, 2006 Does anyone tried this? I know that Jasper reports does not provide any direct functionality to generate reports in TIFF format. I am not sure whether the future releases will include this functionality. Meantime, If anyone tried this, It will be nice if you could post the codeSample as well. Thanks and I appreciate your time in replying to this. Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 23, 2006 Share Posted August 23, 2006 Hi, JasperReports has the JRGraphics2D exporter that should be enough to export to TIFF format using an image specialized library such as JAI. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
ranG Posted August 23, 2006 Author Share Posted August 23, 2006 Thanks Teodord, Appreciate your reply. I know that you are the GURU of Jasper reports, SO I am guessing this question wouldn't be very hard for you. I have a sample application in which I am trying to export my report to graphics2D, While exporting I want to save it in a file as image as I want to convert that image to tiff format using JAI. I am not sure about the foramt of the image output. And also some parameter settings for the exporter. Here's my sample: String reportFileName = "static_report";Map parameters = new HashMap(); try{ JasperReport jasperReport =(JasperReport) JRLoader.loadObject(getServletContext().getRealPath( "/reports/" + reportFileName + ".jasper")); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource ()); JRGraphics2DExporter exporter = new JRGraphics2DExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "simpleReportImg"); exporter.exportReportToGraphics2D(); }catch (JRException e){e.printStackTrace();} Link to comment Share on other sites More sharing options...
ranG Posted August 23, 2006 Author Share Posted August 23, 2006 Thanks Teodord, Appreciate your reply. I know that you are the GURU of Jasper reports, SO I am guessing this question wouldn't be very hard for you. I have a sample application in which I am trying to export my report to graphics2D, While exporting I want to save it in a file as image as I want to convert that image to tiff format using JAI. I am not sure about the foramt of the image output. And also some parameter settings for the exporter. Here's my sample: String reportFileName = "static_report";Map parameters = new HashMap(); try{ JasperReport jasperReport =(JasperReport) JRLoader.loadObject(getServletContext().getRealPath( "/reports/" + reportFileName + ".jasper")); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource ()); JRGraphics2DExporter exporter = new JRGraphics2DExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "simpleReportImg"); exporter.exportReportToGraphics2D(); }catch (JRException e){e.printStackTrace();} Link to comment Share on other sites More sharing options...
sreepriyar Posted May 18, 2007 Share Posted May 18, 2007 Any details on this? Can some one pls reply? Link to comment Share on other sites More sharing options...
Teodor Danciu Posted December 5, 2019 Share Posted December 5, 2019 Hi,TIFF is a multi-page image format and we can use the JRGraphics2DExporter in JasperReports to export reports to multi-page TIFF files.The TIFF files are created using the ImageIO API, which is part of the Java Virtual Machine. However, for Java 8, you would also need this plugin:https://github.com/haraldk/TwelveMonkeysor this other plugin:https://github.com/jai-imageio/jai-imageio-coreSince Java 9, support for TIFF is present in the JVM, so the plugin is no longer needed.Here is some sample code that helps export reports to TIFF: ImageWriter writer = ImageIO.getImageWritersByFormatName("TIFF").next(); try (FileOutputStream out = new FileOutputStream(jasperPrint.getName() + ".tiff")) { try (ImageOutputStream output = ImageIO.createImageOutputStream(out)) { writer.setOutput(output); ImageWriteParam params = writer.getDefaultWriteParam(); params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); params.setCompressionType("Deflate"); float zoom = 3f; writer.prepareWriteSequence(null); int pageCount = jasperPrint.getPages().size(); for (int page = 0; page < pageCount; page++) { BufferedImage image = (BufferedImage) JRPrinterAWT.printPageToImage(jasperPrint, page, zoom); writer.writeToSequence(new IIOImage(image, null, null), params); } writer.endWriteSequence(); } out.close(); } catch (Exception e) { throw new RuntimeException(e); } finally { writer.dispose(); }[/code]Attached is a sample report exported to TIFF using the above code.I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now