Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

python - Generating PDFs from SVG input

I am trying to generate a PDF from a SVG input file with Python in a Django application.

I have already found 2 working solutions: cairo+rsvg and imagemagick but they both have one problem: They have some strange dependencies that I do not want to install on a server, for example DBUS and GTK.

So I am asking for another method for generating a PDF from SVG without having to install all these stupid dependencies on a server.

question from:https://stackoverflow.com/questions/5835795/generating-pdfs-from-svg-input

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have you considered svglib?

It looks quite promising, especially as reportlab is the featured pdf tool in Django's docs.

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPDF

drawing = svg2rlg("file.svg")
renderPDF.drawToFile(drawing, "file.pdf")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...