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
654 stars 101 forks source link

fix fill gradient bug #78

Closed dippindots closed 5 years ago

dippindots commented 5 years ago

Linear gradients and radial gradients can use percentage value as their offset. fix issue: https://github.com/yWorks/svg2pdf.js/issues/77

HackbrettXXX commented 5 years ago

Looks good! Please provide a small test case to verify it works. Have a look at the tests folder and the runTests.js file.

dippindots commented 5 years ago

@HackbrettXXX Sure, thanks for spending time to review my pr. I have some trouble with running npm run createreferences, Could you tell me how to generate the pdf by running this command? Or can I just run the script online and paste the downloaded pdf as the reference?

yGuy commented 5 years ago

Justs nitpicking, but wouldn't "0.5%" be interpreted as "50%"? I know it's unlikely to be a value below 1%, but not impossible: https://developer.mozilla.org/de/docs/Web/SVG/Content_type#Percentage We should check for occurences of the % character and only then do the division by 100, IMHO

dippindots commented 5 years ago

@yGuy Thank you very much for pointing out this problem. I have not considered it before. I will make changes soon.

HackbrettXXX commented 5 years ago

Concerning the references: run npm run createreferences and keep it running. Then run npm run test, which will then create a reference pdf, if it does not exist already. You can force overriding by setting the debug flag in runTests.js to true.

dippindots commented 5 years ago

@HackbrettXXX Thanks for your detailed explanation. I have updated the solution and test case!

HackbrettXXX commented 5 years ago

Thanks for the PR. I merged it.