-
Notifications
You must be signed in to change notification settings - Fork 109
Unexpected Behavior when rendering the same Svg-image on two different Pdf-pages #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From this information alone I cannot reproduce the issue. I can guess that the exception might originate from here: However, this would mean that adding pages is completely broken in jsPDF, which it isn't. Do you call any other jsPDF methods besides the svg() call (e.g. link() or textWithLink())? In order to help you we need to be able to reproduce the issue. Could you share a small example with two SVGs that cause the exception and the code that produces the PDF? |
I can give you the library specific code and two example Svg's for now.
|
Thanks for sharing your code with us. When I run it with the two SVGs, I get a different error:
That's the same bug you reported in #165. However, I could not reproduce your exception. |
Thanks for your research first of all. Back to the topic of this thread: I did analyze my Svg's in detail and detected that the So I encourage everyone that detects such cross page errors to clean up their Svg files, in case their I will let you know if I can detect what exactly crashes the library. |
Hey guys, After more research I found a case for which I could isolate the error better. The two svgs I will attach are just multiple gradient colored lines.
Thanks for your help |
I tested also with non gradient colored lines, the lines are rendered correctly |
Thanks for narrowing it down. The lines don't appear in the PDF because gradients are not supported on strokes. I could also reproduce the PubSub error now. There are two bugs, one in jsPDF and one in svg2pdf: jsPDF
The early exit leaves jsPDF in a bad state, resulting in the exception when writing the pages. The early exit is missing the svg2pdfWe are running into this case, because we render the same SVG twice, resulting in the path with id svg2pdf.js/src/context/referenceshandler.ts Lines 36 to 38 in d6dd5f1
|
Hey guys,
I tried to render the same SVG image in my pdf with the svg2pdf tool on two different pages in the document.
For most of the Svg-files I have that works perfectly.
But for some Svg's I get the following behavior:
Unfortunately I could not isolate the problem better,
except for the fact that when I remove all
xlink:href
attributes it works fine.Since
xlink:href
is deprecated in the Svg-standard, I did also tryhref
instead, but got no positive effects.Not to use
href
is not an option for me.I have seen that the error is thrown by the jsPdf library, but I am not sure if its a problem with the preprocessing of svg2pdf or indeed a problem with jsPdf.
If I can provide more information just let me know.
The Svg's are created with InkScape.
I am using svg2pdf 2.0.0 and jsPdf 2.0.0.
Thanks for your help
Frederic
The text was updated successfully, but these errors were encountered: