generate a hyperlinked table of contents and insert into existing PDF

I have an existing PDF (with no equivalent resource documents), and also a message documents which is a checklist of things referencing areas within the PDF documents, in addition to a web page number for each and every thing. I would love to create a new PDF which begins with a created tabulation index, adhered to by the materials of the initial PDF. The created index requires to be hyperlinked to make sure that clicking any kind of thing will instantly leap to the web page having the referenced area.

I'm seeking an ideal set of devices (ideally CLI - oriented) to complete this on Linux ; all the devices I've considered until now do not appear to supply a remedy. I'm a seasoned designer, and also am greater than satisfied to write code if called for (ideally in Ruby/Python/Perl/ shell) to parse my message documents and also transform it right into a hyperlinked index, yet I can not locate the right devices to address it. I assume component of the trouble is that the links require to indicate within the very same documents, yet their targets will not exist till later on when the ToC is accompanied the initial PDF.

I'm additionally accustomed to numerous markup languages, as an example Markdown, reStructuredText, TeX, LaTeX, org - setting, and also an excellent remedy would certainly make use of among these as an intermediate action for creating the hyperlinked ToC.

14
2022-07-25 20:39:54
Source Share
Answers: 1

This is absorbed entire from @Herbert addressing a really comparable inquiry on the TeX StackExchange:

usage plan pdfpages and also then:

\documentclass{article}
\usepackage{pdfpages}
\usepackage{hyperref}

\begin{document}

\tableofcontents
\clearpage\phantomsection
\addcontentsline{toc}{section}{The first section name}% or chapter
\includepdf[pages={1-10},linktodoc,linktodocfit=/Fit]{texte/dtk/dtk11-1/komoedie.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{section}{The second section name}% or chapter
\includepdf[pages={11-19},linktodoc,linktodocfit=/Fit]{texte/dtk/dtk11-1/komoedie.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{section}{The third section name}% or chapter
\includepdf[pages={20-29},linktodoc,linktodocfit=/Fit]{texte/dtk/dtk11-1/komoedie.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{section}{The forth section name}% or chapter
\includepdf[pages={21-39},linktodoc,linktodocfit=/Fit]{texte/dtk/dtk11-1/komoedie.pdf}

\end{document}
8
2022-07-25 22:36:52
Source