Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Add hyperlinks to PDFs created by Inkscape
#
# Moved to https://github.com/oxplot/gists/blob/master/svglinkify.py
#

Very nice, thank you. Having trouble with one thing: After joining multiple pdfs with pdfjoin the links are gone. Any idea why?

Owner

oxplot commented May 19, 2015

Hmm, that's odd. Mind emailing me the source SVGs?

This is exactly what I was looking for, and saved me a huge headache. Thank you very much for this script.

pszafer commented Jun 9, 2015

Hello,
I have svg and pdf. SVG is bit complicated, with few layers etc.
But from svg your script returning 1 rectangle with link and for created pdf, qpdf is returning 0 rectangles then I've got message about diffs between svg and pdf.
Am I creating pdf in wrong way or how should I do it to work? :)
Thanks for your script and help!

Owner

oxplot commented Jun 9, 2015

It's most likely the "SVG [being] complicated" that's causing you problems. Like I've mentioned in the instructions, the script only works if you've drawn the magenta rectangles with no transformations of any kind. Send me a copy of your SVG if you can, and I might be able to help you further.

Owner

oxplot commented Jun 10, 2015

OK. Here's what I did. I added a new layer and called it "Links" and put it at the bottom. Drew the magenta box over the email address and the website address, and followed the rest of the instructions as described and it works fine. If you want the modified SVG and the resulting PDF, send me an email (it's at the top of the script) and I'll reply with the files.

pszafer commented Jun 10, 2015

I send e-mail :)
Cool that it is working, hopefully it will work for me too.

ralex5 commented Nov 24, 2015

Thank you very much, you made my day ! Your script is just awesome. It was the last tool I needed to make my presentations completely with Inkscape. Great job !

Thanks for this!

I've a problem with your script: it works well for one hyperlink, but it fails when I try to create multiple links/boxes in the same svg file and I get the error message "error: found diff # of rects in svg & ps...". Do you have any idea why it could happen? Thanks!

hcommenges, I found that creating a new layer for EACH rectangle was required. Also make sure that each of these layers is under the layer that contains the text blocks you want to link. I spent an hour on that today and that was what made it work for me.

oxplot, THANK YOU VERY MUCH!

Wonderful! Thanks!
Just a suggestion on the instructions: after adding the box with the link to the SVG file, it is not enough to export it as PDF. One has also to save the SVG. Could you please explicitly add this instruction to the top of the script, please?

It works, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment