Corrupt rendering of SVG dashed lines in PDF

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
User avatar
jeffbronks
Posts: 214
Joined: Fri Mar 04, 2005 12:39 pm
Location: Cambridgeshire, UK

Corrupt rendering of SVG dashed lines in PDF

Unread post by jeffbronks »

* Create a drawing containing solid lines and dashed lines in Adobe Illustrator. Give all the lines the same thickness.
* Save as SVG
* Place SVG as image in H&M7 project
* Compile to PDF
* Zoom in on the lines. Notice that the solid lines are rendered correctly but the dashed lines are made up of distorted shapes instead of perfect rectangles. On my system each dash is a square with three bevelled corners and one indented corner, a bit like a PacMan.

You may think that worrying about the shapes of the dashes when zoomed in is a bit obsessive, but the effect is still visible when zoomed out. The dashed lines stand out as thick and irregular while the solid lines all look neat.

My first thought was to suspect the PDF printer driver setting in H&M7, so I changed it from Microsoft XPS (which I normally use) to Adobe PDF. This had no effect.

Then I started tinkering with the SVG code. I found that the stroke-dasharray attribute was the culprit. Deleting this resulted in a perfectly rendered smooth line. So I think H&M7's SVG to PDF converter is not correctly rendering lines with the stroke-dasharray attribute.
You do not have the required permissions to view the files attached to this post.
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by Tim Green »

Hi Jeff,

Help & Manual 7's SVG implementation currently is what it is. The SVG rendering engine will generally do a good job, but you will experience some SVGs that won't be perfect, and some that will fail in more or less major ways. This will also vary depending on the program that created the SVG as well as the features used in the SVG. Some SVGs will look excellent, some will have annoying detail artifacts and some will be unusable crap. When they are unusable the only alternative at the moment is to convert the image into a PNG with alpha transparency instead.

This will certainly be improved in the future, but for the moment it is what it is... 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
jeffbronks
Posts: 214
Joined: Fri Mar 04, 2005 12:39 pm
Location: Cambridgeshire, UK

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by jeffbronks »

Thanks for that plain statement of the facts! I won't report any more SVG bugs - but it's nice to have basic SVG rendering anyway. Everything was fine until I tried dashed lines.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by Alexander Halser »

Hi Jeff,
not correctly rendering lines with the stroke-dasharray attribute.
PDF commands don't exactly match the functionality of SVG. When possible, HM7 tries to convert the SVG into native PDF drawing commands, because that retains the resolution-independent image quality. But it has its limitations and HM7 analyzes every SVG to determine if it can be translated into PDF commands or if it is too complex. If an SVG is too complex, HM7 renders a transparent PNG from the SVG and embeds the PNG instead. The resulting picture in the PDF is identical to what you see at design time in the editor. I think that this SVG is rendered natively in PDF, but some attributes are not supported.

Please send me the image in original SVG format to test it. My address: alexander.halser * ec-software.com
Alexander Halser
Senior Software Architect, EC Software GmbH
Simon Dismore
Posts: 454
Joined: Thu Nov 16, 2006 1:29 pm
Location: London, UK

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by Simon Dismore »

Alexander Halser wrote:HM7 analyzes every SVG to determine if it can be translated into PDF commands or if it is too complex
I'd be interested to know which SVG attributes and/or styles should be avoided when generating SVGs for use with HM7.

Thanks for any advice.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by Alexander Halser »

Currently, H&M considers an SVG image as too complex for PDF if it used gradient fills (radial or linear gradients).
Alexander Halser
Senior Software Architect, EC Software GmbH
User avatar
jeffbronks
Posts: 214
Joined: Fri Mar 04, 2005 12:39 pm
Location: Cambridgeshire, UK

Re: Corrupt rendering of SVG dashed lines in PDF

Unread post by jeffbronks »

FYI I happened to open one of these incorrectly rendered PDFs in Adobe Illustrator today. It was immediately obvious what Help and Manual's SVG to PDF converter had done wrong. Each dash in the dashed line was rendered as two objects: a filled rectangle and a stroke wrapped around the rectangle. The filled rectangles by themselves would be enough to render the dashed line correctly. The 'wrapper' is what causes the visual problem: it is drawn as a open polyline with bevelled corners. The PDF viewer is forced to draw a tiny bevelled polyline around every dash, which is what makes the dashed line look lumpy at a normal viewing scale. If the SVG to PDF converter could just stop drawing the polylines, all would be fine.

This might not be of any interest to you but perhaps you could feed it back to the developers of the SVG renderer. Maybe they will fix it one day.
Post Reply