lelo.endrik Posted February 1, 2014 Share Posted February 1, 2014 Greetings experts,I am new to the jasper world, so my question might be quite simple. I wish to generate a report from my java application. It work fine when it comes to pdf and excel formats, but i want to try to export it as an image (such as jpg, png the extension is not important). Is there any class like JPdfExporter or any other easy way to achieve this? During my researches, i've came across JRGraphics2DExporter, but i didn't understand how it works, and if this is the right choice of what i'm trying to accomplish. I would like an example of it's usage.Thank you in advance! Link to comment Share on other sites More sharing options...
hozawa Posted February 2, 2014 Share Posted February 2, 2014 Did you try using JasperPrintManager.printPageToImage()http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperPrintManager.html Link to comment Share on other sites More sharing options...
lelo.endrik Posted February 3, 2014 Author Share Posted February 3, 2014 No,, actually it's the first time i see this options. Thank you, i'm gonna try it asap! Link to comment Share on other sites More sharing options...
Solution lelo.endrik Posted March 24, 2014 Author Solution Share Posted March 24, 2014 A bit late in replying, but i thought this solution might be useful to someone else. I've managed to get JRGraphics2DExporter to work, and it doesn generate a correct .png image.[/code] JRGraphics2DExporter exporter = new JRGraphics2DExporter(); BufferedImage bufferedImage = new BufferedImage(595, 860, BufferedImage.TYPE_INT_RGB); Graphics2D g = (Graphics2D)bufferedImage.getGraphics(); exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, g); exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, Float.valueOf(1)); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); attrs.add(new PrinterResolution(500, 440, ResolutionSyntax.DPI)); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, attrs); exporter.exportReport(); g.dispose(); ImageIO.write(bufferedImage, "PNG", out); Link to comment Share on other sites More sharing options...
nicknxswart.nl Posted June 12, 2021 Share Posted June 12, 2021 Did you managed to get the report as an image? can you share on how you did this? We in a use case need a report that is generated by the Rest API as a image instead of PDF. 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