How to insert a SVG file in a PDF document?

2019-01-26 18:34发布

I'm trying use embeddSVG.py to embed an SVG in a PDF, but Adobe Acrobat Reader doesn't show svg content in my pdf.

标签: python pdf svg
3条回答
Juvenile、少年°
2楼-- · 2019-01-26 19:22

Maybe you can use svglib to convert your svg to pdf and then include it using pyPdf. Note that svglib seems to use reportlab so you can probably use their api to manipulate your file.

查看更多
做自己的国王
3楼-- · 2019-01-26 19:23

You're probably better off first converting the SVG to PDF.

Apache Batik includes SVG Rasterizer, which, despite its name, can convert SVG to PDF.

This is used by Apache FOP to convert Docbook documents that include SVG graphics to PDF.

查看更多
走好不送
4楼-- · 2019-01-26 19:34

Save the SVG as a PDF, and then open the PDF in Acrobat.

For example, if you create the SVG in Inkscape, then you would go to File -> Save a copy -> Save as PDF, and then open it up in Acrobat. This method should preserve text and vector paths.

If you instead choose Print -> Print to File as PDF, then the image will become rasterized (pixelated) and lose its vector powers.

You may also save your SVG image as a DWG file or as an EMF file, both of which are easier formats to open/import into Acrobat than an SVG. (Note to Adobe: "Hey, Adobe, it's time to start supporting direct SVG imports into Acrobat!")

If you are working with SVGs, Inkscape or a similar program (Illustrator or CorelDraw) is essential. Inkscape is free.

查看更多
登录 后发表回答