How can I import the reference of content to table of content of the imported PDF in the global document?

I'm writing a bilingual book combined with ENG - FR the idea is to generate the first book in FR then import it inside the ENG one, all is good with this code

\AtEndDocument{\includepdf[pages=-]{21stskills4testers_FR_just_for_test.pdf}}


But the problem, the reference to table of content of the imported PDF (FR) disappears.

Can I import a PDF without loosing it's reference of content ?

• No. I don't believe you can do this. But I believe there are some tricks discussed somewhere around here which might let you add some links back in. It might, however, be easier not to do it this way. – cfr Dec 4 '20 at 5:33
• Thank you for your feedback! Do you mean tricks in the PDF it self after being generated ? or I call 2 projects at the same time ? – Emna Ayadi Dec 4 '20 at 9:28
• I think I've seen discussion of post-processing the PDF to restore some of the links. But it is certainly a smoother ride if you do it as one document. – cfr Dec 5 '20 at 2:35

Using pdfpages you cannot import the TOC, but you can recreate it. But I don't think this is worth the effort in your case. Especially not, when you are writing both versions of the book. In this case I would consider \include instead of \includepdf. See the example below.

Anyway, assuming that you have only the PDF (not the LaTeX source), then it might be reasonable to recreate the TOC like this:

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{hyperref}

\begin{document}

\includepdf[
pages=-,
1, section, 1, aaa, sec:aaa,
2, section, 1, bbb, sec:bbb,
3, section, 1, ccc, sec:ccc
}%
]{dummy.pdf}

\end{document}


But since you are writing both versions of the book, and have the LaTeX source of both, the following approach is much better.

English version of your book. File content-en.tex.

\section{English}
\lipsum


French version of your book. File content-fr.tex.

\section{French}
\lipsum


And finally the main document, where you include both versions or just one or the other.

\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\include{content-en}
\include{content-fr}
\end{document}