TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have generated PDFs with figures that have hyperlinks (hyperref to websites, \href) in them. When I compile these figures standalone the hyperlinks work. But when I try to include these PDFs (as figures, not the sources) with \includegraphics the links are lost and only the image is inserted in the document.

Is there a way to include (\includegraphics?) a PDF such that its original links work in the master document?

This question has to do with the externalization (e.g. TikZ or PGFPlots), which also suffers from these drawbacks, i.e. hyper-references are lost.

share|improve this question
@ diabonas: I saw your solution when I searched "preserving hyperlinks in compiling to Android": tex.stackexchange.com/questions/14620/… Following your "how to use pax" I got stymied following your solution at: > Run pdfannotextractor.pl --install. This downloads and installs > PDFBox, a Java library necessary for using pax. While I can "open" the .pl file and read the code using Notepad++, I can't run it in order to install PDFBox. I read elsewhere that in order to do this requires a webserver CGI script - see file.org/extension/pl# I'm a – user2883866 Oct 18 '13 at 17:09
up vote 18 down vote accepted

You can not simply mix two PDF files. You have to preserve PDF document structure. In the simply case links (PDF annotations) are dropped.

You can try the PAX project, which trys to extract and reinsert the PDF annotations.

share|improve this answer
although using a Java from PAX is far from ideal I will mark this as accepted answer until a better option appears. – alfC Apr 5 '11 at 7:36
For an example on how to use pax, see Embedding a pdf file with clickable external links into a LaTeX document – diabonas Feb 16 '12 at 14:37
Thanks Josef and @diabonas, your trick worked like a charm! – AndreasT Apr 26 at 17:35

It seems that pdftex always drops all PDF annotations (which includes hyperlinks) from the included file.

The PDF format itself makes it rather difficult to do otherwise. PDF annotations are laid out in a completely different way to how the rest of the content of the page is constructed. They live on a different layer and they are positioned using a different (page-absolute) coordinate system.

share|improve this answer
Difficult doesn't mean impossible. Plenty of pro PDF tools do it (Acrobat Pro being one of them), so it's sad (pdf)latex doesn't include that feature… – F'x Mar 22 '14 at 20:55

It works with luatex. However, it is not considered to be stable. Here a context example:

\setupinteraction [state=start]


  \startbuffer [internal]
    \setupinteraction [state=start]
      \useURL [aurl] [http://xkcd.com/149/] [] [I prefer hot dogs.]
      \from [aurl]

  \savebuffer [internal]
  \executesystemcommand {context --purgeall \jobname-internal.tmp}

  \externalfigure [\jobname-internal] [scale=500, interaction=yes]



  • The buffer contains the code for a PDF file with a hyperlink.
  • The \savebuffer writes the content of the buffer internal in an external file.
  • \executesystemcommand runs context on this file to create the PDF file containing the link.
  • Eventually the externalfigure command includes the just created PDF in the current document.

Tested with luatex beta-0.70.1-2011051923 and context 2011.11.04 14:15

share|improve this answer
I am not familiar with LuaTeX but I will try to give it a try, Is this exploiting the fact that the PDF is generated inside the same document? also, Is there a fundamental reason why this can't be translated into LaTeX? – alfC Nov 7 '11 at 6:28
No, it has nothing to do with the fact that the internal PDF is generated on the fly. I used it in the example to make sure that the embedded file contains a file with a valid hyperlink. The functionality could be make available within a LaTeX package. No one felt like writing a package for this, yet. I don't use LaTeX, that's why I can't help you with a LaTeX hack. – Marco Nov 7 '11 at 8:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.