yWorks/svg2pdf.js

stroke-width="inherit" breaks in jsPDF

KacperMadej opened this issue · 2 comments

Describe the bug
An error is thrown Error: Invalid argument passed to jsPDF.scale when stroke-width="inherit" is used.

To Reproduce
See this playground.

Expected behavior
I would have expected the PDF to look like so.
image

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
  <g stroke-width="3">
    <path fill="yellow" d="M 20 20 L 50 50 L 20 50 Z" stroke="red" stroke-width="inherit"></path>
  </g>
</svg>

Desktop:

  • OS: Windows 11
  • Browser: Chrome ()
  • Chrome Version 104.0.5112.102 (Official Build) (64-bit)

Additional context
It might be a purely jsPDF bug but I am not able to recreate a simple demo to report the problem there - if this is the case and you could help with passing the bug report to the correct place I will be grateful.

yGuy commented

Thanks for the report and repro. I am not 100% sure whether inherit is actually a valid value, here? This is not CSS but a presentation attribute and the way I read the spec I don't think you can have it here. At least you don't need it because if you simply omit it, it results in the behavior that you are looking for and the value will be inherited from the g element. And this actually works with the PDF export, too

Thank you for the fast reply. I am not able to find the proper SVG spec for that so this is probably not valid and, as you pointed out, not really needed. I think it is safe to close the issue.