Convert SVG to PDF in Django with Inkscape

We can convert a SVG to PDF file using the following command line provided by Inkscape Vector Graphics Editor:

$ inkscape -z -C -A /path/to/drawing.pdf -f /path/to/drawing.svg

Convert drawing.svg to drawing.pdf, using the entire page (option -C), and NOT using any GUI (-z).

With subprocess python module, we will take advantage of that tool in python:


>>> command = ["inkscape", "-z", "-C", "-A", "/path/to/drawing.pdf", "-f", "/path/to/drawing.svg"]
>>> subprocess.call(command)



Awesomeness!!1

Comments