2013-05-22

How to create a PDF file with a single hyperlink in it

This blog post explains how to create a PDF file with a single hyperlink in it. Such PDF files are useful as hyperlinks uploaded to prezi.com presentations, because as of 2014-05-22 prezi.com doesn't support hyperlinks with text different from the link target URL: it only supports hyperlinks whose URL appear visually in the presentation. By uploading a PDF with a hyperlink this limitation can be circumvented.

Use this Python script to generate the PDF with a hyperlink. It will create a single page PDF containing green triangle with a hyperlink pointing to the URL specified in the command-line. Example usage on Linux:

$ wget -O linkpdfgen.py \
    https://pts-mini-gpl.googlecode.com/svn/trunk/linkpdfgen/linkpdfgen.py
$ chmod +x linkpdfgen.py
$ ./linkpdfgen.py http://example.org/ output.pdf

To insert the generated PDF file to prezi.com, choose Insert / From file when editing the presentation.

Please note the generated PDF file is very small (about 700 bytes). This is not a coincidence, the file contains only the minimum amount of information necessary.

Non-alternatives on Linux:

  • Adobe Acrobat: This software is not available on Linux.
  • Inkscape: Inkscape 0.48 can't export a PDF containing hyperlinks. (All hyperlinks are removed when the PDF file is saved.)
  • OpenOffice or LibreOffice: They can't add hyperlinks to geometrical shapes, so the generated PDF will have to contain text, thus it has to contain fonts, thus it will be larger than necessary.

No comments:

Post a Comment