从SVG输入生成PDF [英] Generating PDFs from SVG input
问题描述
我已经找到2个工作解决方案:cairo + rsvg和imagemagick但是他们都有一个问题:他们有一些奇怪的依赖关系,我不想在服务器上安装,例如DBUS和GTK。
所以我要求另一个从SVG生成PDF的方法,而不必在服务器上安装所有这些愚蠢的依赖。
您是否考虑过 SVGALib之上?
看起来很有希望,特别是因为reportlab是特色pdf工具在Django的文档中。
>>>来自svglib.svglib import svg2rlg
>>>来自reportlab.graphics import renderPDF
>>>>
>>> drawing = svg2rlg(file.svg)
>>> renderPDF.drawToFile(drawing,file.pdf)
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.
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")
这篇关于从SVG输入生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!