yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
649 stars 98 forks source link

Missing paths in SVG due to empty clip-path attribute #180

Closed zornwal closed 3 years ago

zornwal commented 3 years ago

Describe the bug My SVG is missing paths when printing. They ought to be there and are rendered correctly in the playground SVG preview, but are also missing in the playground PDF preview.

jspdf@2.3.1 svg2pdf.js@2.1.0

To Reproduce Use the playground

(full svg)

Expected behavior I would have expected the paths in the graph to be included. I am aware that fonts need to be included in order to perfectly mirror the rendered svg.

Screenshots rendered svg (and expected pdf) actual pdf

Desktop (please complete the following information):

HackbrettXXX commented 3 years ago

Thanks for the issue report. Please try to reduce your SVG until only the missing path remains.

zornwal commented 3 years ago

Apologies, I have updated with a link to the playground with just the disappearing path.

yGuy commented 3 years ago

Obviously this is caused by the empty clippath attribute. Of course the workaround would be to remove it.

zornwal commented 3 years ago

If I remove the clip-path, the line will be visible through the nodes on the graph, though. If there is no other course of action, I will remove the nodes (and the clip-path). Why is an empty clip-path an issue? (I know next to nothing about SVG)

yGuy commented 3 years ago

Well, this might be just a bug in svg2pdf, but as to why an empty-clip path might be an issue, you should ask the standard committee.

Empty clip paths are not allowed and against the spec, I would say - use "none" (which is the default), if you don't need a clip path: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/clip-path

I guess though, that you stripped-down the example a bit too much and that you still need a clip path and the original problem is another problem

HackbrettXXX commented 3 years ago

Seems to be a small bug in svg2pdf:

An IRI reference to another graphical object within the same SVG document fragment which will be used as the clipping path. If the IRI reference is not valid (e.g it points to an object that doesn't exist or the object is not a ‘clipPath’ element) the ‘clip-path’ property must be treated as if it hadn't been specified.

https://www.w3.org/TR/SVG11/masking.html#ClipPathProperty

jagnathan commented 3 years ago

hi @HackbrettXXX will this fix be included in the next release of svg2pdf? I am interested to know the date for the next release of svg2pdf. thanks

HackbrettXXX commented 3 years ago

@jagnathan yes it will be included in the next release but I can't tell you exactly when we will release it. Depends on the next release of jsPDF.