C-Box Posted May 31, 2012 Share Posted May 31, 2012 Hi,we produce JasperPrint Objects as normal. But we store the printouts (as byte array) in database as JasperPrintXMLs as follows:JRXmlExporter exporter = new JRXmlExporter(); exporter.setParameter(JRExporterParameter.CLASS_LOADER,new AfpsDruckFontExtensionTTFLoader(Thread.currentThread().getContextClassLoader())); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outXML); exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.TRUE); //exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING,new String("UTF-8")); exporter.exportReport();This is necessarry as we can open the old output even with newer releases of JasperReports as this is class independed (we still have some as xml outputs from 0.5.3 in database when I remember right)When we need a PDF file (for mail delivery or anything else) we convert this JasperPrintXML back to a JasperPrint as follows:ByteArrayInputStream inXML = new ByteArrayInputStream(xml); JasperPrint jasperPrint = JRPrintXmlLoader.load(inXML);and then use the JRPdfExporter with the JasperPrint again:JRPdfExporter exporter = new JRPdfExporter();ByteArrayOutputStream outPDF = new ByteArrayOutputStream();exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outPDF); exporter.exportReport();But in the resulting PDF the SVG is rendered like a normal Image (quite pixelated)....When I generate the PDF from original JasperPrint Object (without the JasperPrintXML between) it's ok - even with zoom to 6400% in AcrobatReader.So why the SVG quality got lost when storing the JasperPrint as XML (with embedded images) between?The Ultimate guide tells:The quality of this exporter is equal to the Graphics2D exporter because it preserves100% of the initial document content and properties. There is no loss in documentquality when exporting to XML because the resulting XML content can be loaded backinto a JasperPrint object that will look the same as the original one.So I actually expected that also SVG-Graphics are stored as Base64encoded Images in JRPXML and are loaded back correctly!??!regards from GermanyC-BoxPS: currently working with 4.1.1PPS: I attached two sample PDFs demonstrating the quality .. just zoom a bit to the little ant in the top of page1Post Edited by CBox at 06/01/2012 07:10 Link to comment Share on other sites More sharing options...
lucianc Posted June 5, 2012 Share Posted June 5, 2012 I think that the ultimate guide paragraph was written a long time ago, before JR had SVG images.The XML exporter actually rasterizes all SVG images, and when you reload the report from XML the image is no longer vectorial. To improve the quality of the rasterized images you can set a higher value for the net.sf.jasperreports.image.dpi property.We are going to rethink the XML exporter functionality so that SVG images are preserved.Regards,LucianPS: You can also consider directly storing serialized JasperPrint objects. We are committed to ensure backward compatibility for such objects, and even if there were occasional problems with that they got fixed as soon as we learned about it. Link to comment Share on other sites More sharing options...
C-Box Posted July 31, 2013 Author Share Posted July 31, 2013 Hi Lucian,was there any bugfix within one of the latest versions (> 4.7.0) concerning saving SVG images in JasperPrintXMLs ?(There is another customer who recognized that the qualitity got lost after saving the printouts -> see my first posting)regards from Dresden/GermanyC-Box 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