Add hyperlinks to PDFs made by Inkscape

Latest version of Inkscape supports exporting links now so no more need for this tool.


Inkscape despite being the most wonderful vector graphics editor program out there, has bummed me every time I tried to export something as PDF with hyperlinks in it. Inkscape does support adding links to arbitrary objects but in the conversion process to PDF, that metadata is lost. The reason for this loss (persumably) is that Cairo, a solely graphics rendering library used by Inkscape for outputting PDF, has no notion of object metadata. It just draws stuff to various types of canvas, like bitmaps, PDF, etc.

svglinkify demo PDF output

The final PDF generated by svglinkify which has clickable hyperlinks. See the source SVG file and the Inkscape exported PDF based on which the above is generated.

Being lazy (good thing) and not knowledgeable enough about Inkscape development, I set out to fix this problem quickly such that it can help me (and others) here and now, not in some unknown time in the future. This smells like it requires hackery and that’s exactly right. With less than 200 lines of python code, I made a very simple script that takes an SVG and a PDF of that SVG made by Inkscape, and creates a final PDF that has clickable hyperlinks. The SVG needs some simple treatment which is described in detail in the header comments of the python script. I have also made a demo SVG, and the PDF output of the script which can be seen on the right.

You can get svglinkify from my repo. You need python 2 or 3, qpdf and of course Inkscape to make everything work.