Jump to content
We've recently updated our Privacy Statement, available here ×

Image quality when SVG exported to HTML


nsushkin

Recommended Posts

I have a report which contains SVG images. While in PDF, the SVG image is perfect (being exported as curves), in HTML export it looks bad. I analyzed the image, it contained only one color, I suspect the antialiasing wasn't enabled. I explicitly enabled antialiasing in BatikRenderer using java.awt.RenderingHints and the exported image now looks much better. I am attaching a patch and the old and new images for your consideration.

Also, although I am not sure, the same issue may be applicable to the Excel image problem described in thread "Excel image quality - awful" at http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=30573

ps. using batik from jasper reports 3.5.0

 

Code:
--- src/net/sf/jasperreports/renderers/BatikRenderer.java~      2009-05-29 11:05:47.000000000 -0400+++ src/net/sf/jasperreports/renderers/BatikRenderer.java       2009-06-03 11:45:59.000000000 -0400@@ -28,6 +28,7 @@ package net.sf.jasperreports.renderers; import java.awt.Graphics2D;+import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D;@@ -141,6 +142,12 @@                                        SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE, true,                                        (float) rectangle.getWidth(), (float) rectangle.getHeight());                        Graphics2D graphics = (Graphics2D) grx.create();+            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);+            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);+            graphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);+            graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);+            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);+            graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);                        graphics.translate(rectangle.getX(), rectangle.getY());                        graphics.transform(transform);
Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

hey, this what my problem is..... when I export to HTML images get distorted.  Please refer to the links below--

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=53480 and please see the attached image.  Or see attached image.

If you don't mind, may I know how your solution can help me ? How to use your patch ?

Thanks in advance,

Sagar

 

 

Link to comment
Share on other sites

The SVG distortion in SVG should be fixed in JR 3.5.2.  Could you give it a try and let us know whether it works fine?

Regarding the rendering hints, that's a good patch.  We'll look into incorporating it into the codebase (maybe make this configurable somehow).

Regards,

Lucian

Link to comment
Share on other sites

Hi Lucian. Nice to see your reply. I followed your suggestion. Color quality is improved , but problem of image distortion is still there. Also, I have not applied any gradient to the bars.Still the color of the bars has gradient.

Please see the screenshot of the bar rendered . This is being shown in liferay portal.

 

 

Thanks,

Sagar



Post Edited by csagar at 06/05/2009 04:07
Link to comment
Share on other sites

Sagar,It looks like your image is being resized using a poor quality algorithm. It could be either by the browser, if you have a mismatch between the actual image size and the size specified in html with CSS or height/width attributes on the img tag. Take a look at the html source. Alternatively, maybe it's Jasper trying to resize the image with a poor algorithm. Perhaps my patch can help. If you don't know how to apply the patch yourself, wait for Lucian to release a version which incorporates my patch.

 

Nicholas Sushkin

 

Link to comment
Share on other sites

I think I misunderstood what mean by "distorted".  Is it about the image quality, or about the image proportions?

The colors probably come from a chart theme.  Do you specify a theme for the chart?  Or maybe you have a custom default theme.

Regards,

Lucian

Link to comment
Share on other sites

  • 6 years later...

Hi,

I'm using JasperReports Server 5.1.0 and I'm still experiencing image quality loss when exporting SVG to HTML.  When exporting to PDF, the output is clean.

Is there any parameter or configuration we should do to make it work?

Thanks

Charles

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...