How to append two PDFs that have links

pdfpdflatexpdftk

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

worked, but links don't link to the correct pages any longer.

Best Answer

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!

Related Question