Open potatosalad opened 4 years ago
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.
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.
Oh, very interesting! So yes, this is useful. I will merge it soon.
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 theleft
andtop
style properties on theoutputEl
itself.This allows us to use
page.pdf
for PDF output and continue to useelementHandle.screenshot
for PNG and JPEG output.