2008
I recently had the need to dynamically create PDF files based on Adobe Illustrator (*.ai) files created by a talented artist. The application allowed the user to embed his name on the resulting pdf file, and I had to make sure the quality of the drawing wasn’t lost, since it was going to be used for printing. Therefore I turned to SVG, a wonderful XML-based file format for vector images.
XML files are relatively easy to work with on the server, so by converting the AI file to SVG I was able to edit the drawing dynamically. But it turned out converting SVG to PDF on the fly wasn’t as straightforward as I thought. Fortunately a colleague at work found out a very nice way to do it by using an application called Inkscape. It was a bit hard to get the dependencies working on the RHEL server we had, but he finally managed to get it going.
If you’re using Ubuntu, there’s nothing to worry about, Inkscape is as easy to install as running the following on your command line:
sudo apt-get install inkscape
Inkscape has an option for using it as a command-line tool, this is what you must run in order to convert SVG to PDF:
inkscape -z --file=original.svg --export-pdf=converted.pdf
For it to work properly you have to make sure you have the latest Cairo libraries installed.
Here’s an example of the result:
This process also embeds the necessary fonts defined in the SVG into the PDF file.
Hope this is useful to someone.









thx, that was useful
using “man inkscape” I’ve learned that there are also some other useful options apart from “-z”. For example I use this function to convert all SVG files from current folder into PNG format:
function svg2png() {
for file in $(ls *.svg);
do
inkscape -D -e ${file%.svg}.png ${file} ;
done
}
cheers
Tomek
Thank you, I was looking for a SVG to PDF converter – I can now run a script to ensure all my images are up to date before compiling my latex.
this is just what i needed to get svgs into latex. thanks!
just what i was looking for – thanks!
Thanks, this just saved my day!
Very useful, thanks!
This works much much better than “saving as” PDF inside the Inkscape GUI!