Skip to content
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 support for PDF output #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

potatosalad
Copy link

I realize that PDF support was previously supported and later removed, but I had a need for SVG 1.1 to PDF conversion support and thought it might be worth revisiting.

This tool, in my opinion, produces the most accurate PDF results in comparison with other tools I've tried (rsvg, cairosvg, svglib, and many others).

Main change is that CSS on the SVG element itself for transform: translateX(${-clip.x}px) translateY(${-clip.y}px) compared with modifying the left and top style properties on the outputEl itself.

This allows us to use page.pdf for PDF output and continue to use elementHandle.screenshot for PNG and JPEG output.

@shakiba
Copy link
Collaborator

shakiba commented May 3, 2020

Sorry for delay and thanks for making the PR, it looks great. One question that I have is that how converting svg to pdf is different from converting to png/jpeg and then converting image to pdf.

@potatosalad
Copy link
Author

PNG to PDF results in a rasterized version of the image that is not as suitable for printing. Writing straight to PDF results in a vectorized version of the image.

@shakiba
Copy link
Collaborator

shakiba commented May 4, 2020

Oh, very interesting! So yes, this is useful. I will merge it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants