Table of content automatic for PDF

Hello,

I post this message because i need a functionality but i don’t know how i can do that.

In my application (in Java), I have an export process that take somes pdf file (sometime lot of pdf files) and that concatenate in one file.

This is pretty simple, i use a PdfFileEditor.concatenate(). BUT i would want to genrate a table of content of the files put in this file and put this table in the beginning of this concatenated file.

Do you think it’s possible ? Something already exist ? I need to do that specificly in my code, but how i can ?

Many thanks in advance for your help.

Best regards

@yanngm

While concatenating the PDF documents, you can get page count from every PDF to keep the information about at which specific page number a PDF would end and a particular PDF will start. Once you keep that information, you can use below code example and use your custom headings and saved page numbers to build a TOC in the final resultant document: