-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
Add page.drawSVG(path) method #202
Conversation
77eb872
to
9d4b92c
Compare
@Hopding let me know what you think. |
Hello @jlmessenger! This is certainly a feature that I'd like to get into pdf-lib. So thank you for working on this. I'm planning to do a thorough review within the next week. However, I've looked over this briefly and a few things pop out at me:
As I mentioned, I'll try to do a more thorough review of the code itself soon. Please let me know if you have any questions/concerns! |
@Hopding - I went ahead and renamed the method to My main goal with this PR is getting feature parity with pdfkit's SVG path support, allowing projects to migrate from pdfkit to pdf-lib. Full SVG support would require XML parsing, and support for a variety of additional svg tags. In my experience manually converting SVG text and shape elements to pdf-lib's built-in methods is trivial, except for There are no unit tests for the SVG path code in pdfkit, and I'm not very knowledgeable about the arc solving math. I was able to find some integration tests, so perhaps those can be ported to the tester apps in some way. I kept the original code and modifications as separate commits in the PR, so you can see how little I modified the code to make it pdf-lib & typescript compatible. I'll see what types of tests I can come-up with, perhaps just ensuring the correct operation arguments are emitted for some sample paths? Suggestions, ideas or support on that is appreciated. Thanks! |
I think the best way to test the I hope this helps. Please let me know if you have any additional questions! |
c704fc2
to
cfda79d
Compare
@Hopding I've also added the curves and shapes from that SVG path spec into the test applications. Please verify the android output, but I was able to inspect the others. Hopefully that checks the last few boxes for you to feel comfortable moving forward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlmessenger This looks great! The tests are very thorough. Thank you for adding them.
These changes will go out in the next pdf-lib release. Probably within the next few days.
* Import original SVG Path code * Add page.drawSvgPath() method * Include svg path tester apps
Brought over the SVG path methods from
pdfkit
, with attribution and updated to TypeScript.Addresses issue: #114
Here's a sample test page with the output with variations on the options.
https://gist.github.com/jlmessenger/c8323fcb7891f30843e59a391cae925a