Skip to content

Add support for PDF output#78

Open
potatosalad wants to merge 1 commit intopiqnt:masterfrom
potatosalad:add-pdf-support
Open

Add support for PDF output#78
potatosalad wants to merge 1 commit intopiqnt:masterfrom
potatosalad:add-pdf-support

Conversation

@potatosalad
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants