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.

  • @ 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 Commented Oct 18, 2013 at 17:09
  • 1
    @alfC Please look at this : tex.stackexchange.com/a/423471
    – AlexG
    Commented Mar 28, 2018 at 14:09

6 Answers 6


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.


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.

  • 6
    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
    Commented Mar 22, 2014 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

  • 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
    Commented Nov 7, 2011 at 6:28
  • 3
    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
    Commented Nov 7, 2011 at 8:02
  • As of 2017-01-05 it does not work with lualatex 1.0.0 and pdfpages 2016/12/11 v0.5g.
    – koppor
    Commented Jan 5, 2017 at 7:16

Since it's an old question, this tiny contribution might be useful in 2022 :)

I merged multiple pdf files on ilovepdf (there are many other sites of that type, but this one worked and did not have any stamp on the result pdf).

The merged file actually conserved the all url/links.

  • thank you. the original question was about pdfs (e.g. pdf figures) includes in pages created by latex, no about simply shuffling pages or merging documents.
    – alfC
    Commented Apr 15, 2022 at 23:30
  • In Linux, one can also use pdftk. Commented Jul 15 at 9:22

There is a way to indirectly make the original links accessible if the embedding .pdfs can be supplied together with the aggregated one: the embedding .pdf can become a hyperlink by itself using \includepdf[linktodoc=true,.... In such a way, the embedded document is opened on click and its hyperlinks become accessible.

Here is the pdfpages manual, where the linktodoc flag is described.

  • Interesting, however this assumes that the original PDF files is still available. I think it can be useful for other things still. It remind me of this other question: tex.stackexchange.com/q/19117/1871
    – alfC
    Commented Mar 18, 2020 at 1:49

For me the pax project (by now hosted on github) mentioned above worked out of the box.

  • 1
    Welcome to TeX.SE!
    – Mensch
    Commented Jul 11, 2022 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .