# How can I append two PDFs that have links

## My problem

I have two PDFs which I would like to merge to one PDF. The first one was generated with LaTeX and has links to the chapters, the second one is a GUI-draft with links created with Balsamiq.

How can I append the GUI draft to the LaTeX document with working links?

## What I've tried

pdftk LatexDocument.pdf GUI.pdf cat output merged.pdf


• Did you ever figure out a good solution for this? – kylex May 18 '13 at 1:20
• @kylex: No. It seems to be impossible to merge two PDFs while keeping the link structure of both PDFs. I "solved" this problem by referencing to the other PDF as text ("See file 'GUI.pdf'") :-/ – Martin Thoma May 18 '13 at 7:12

You might like to try the recently launched Advanced PDF Manipulation tool : Sejda

It has different merging options available (it might work for you)

http://sejda.com/

• No, it doesn't work. – Martin Thoma Dec 9 '12 at 18:03
• @Moose: Thx for letting me know. If I find out further info I'll post it for you. – Simon Dec 9 '12 at 18:22

From within LaTeX you can include the other PDF, GUI.pdf, using pdfpages. Try something like this:

\documentclass{report}
\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
% Other preamble content
\begin{document}
% LaTeXDocument content
\includepdf{GUI.pdf}
\end{document}


If the two documents have different page/stock sizes, pdfpages will rescale the included document to the source page sizes. To avoid this, use

\includepdf[noautoscale]{GUI.pdf}


and any additional options you may require. Read the pdfpages documentation for more information on the operations that can be performed on the input pages.

• Well, the problem with that solution is that both PDF-files have different page sizes. I didn't figure out how to include a PDf with pdfpages without resizing. – Martin Thoma Dec 11 '12 at 18:38
• @moose: Did you read the documentation I linked to? Use the option noautoscale (page 4), since page sizes are automatically rescaled by default. I'll update my answer. – Werner Dec 11 '12 at 18:44
• Yes, I read the documentation. I tried this command \includepdf[pages=-,fitpaper=true,noautoscale]{../GUI/rendered/Entwurf.pdf}, but it did resize Entwurf.pdf (my GUI) to A4. I also tried it with fitpaper=true which also didn't work. – Martin Thoma Dec 11 '12 at 18:51
• @moose: It seems like your options fitpaper and noautoscale are contradictory. What about only noautoscale or with fitpaper=false? – Werner Dec 11 '12 at 18:53
• Only noautoscale didn't work. The image one the page didn't get scaled, but the page size of the document the GUI gets attaced to is wrong (A4). With only fitpaper=true the page size changed from A4 to the exotic one, but the image is ... well, not completely on the page. It's a bit to far at the top left. So I can't see the top/left part, but at the bottom/right is free space. And - by the way - the links get completely filtered. So even if it got correctly attached, I would need the links. – Martin Thoma Dec 11 '12 at 19:02

I found the answer to this question over at the TeX stackexchange: https://tex.stackexchange.com/a/8665

i.e. use ghostscript!

\$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf source1.pdf source2.pdf source3.pdf etc.pdf


I found that unlike other utilities I tried, and the \includedpdf{} command mentioned here, the above gs command preserved my links when merging 4 pdfs, at least for my LuaLaTeX generated file.

Only one of my files contained links, but merging it in multiple times seem to preserve the right order.

Hope that helps!