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
646 stars 96 forks source link

stroke-width="inherit" breaks in jsPDF #227

Closed KacperMadej closed 1 year ago

KacperMadej commented 1 year ago

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:

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 1 year ago

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

KacperMadej commented 1 year ago

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.