Jump to content
Changes to the Jaspersoft community edition download ×

SVG quality in PDFs vs. JasperPrintXML


C-Box

Recommended Posts

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 Germany

C-Box

PS: currently working with 4.1.1



PPS: I attached two sample PDFs demonstrating the quality .. just zoom a bit to the little ant in the top of page1



Post Edited by CBox at 06/01/2012 07:10
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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,

Lucian

PS:  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

  • 1 year later...

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/Germany

C-Box

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...