OpenPdf/PdfBox automatically generate table of contents

917 Views Asked by At

In my current java/springboot project, I need to create a PDF dynamicaly containing paragraphs, images and tables. And I also need to add the table of content of this document.

I'm wondering if there is a way to automatically generate this table of contents using either openPdf or pdfBox.

I noticed that it is possible to do so using IText, but it is not free...

Thanks in advance for your help.

2

There are 2 best solutions below

0
On
0
On

Actually neither openPdf nor pdfBox provide a way to automatically generate table of contents :-(

iText provide us with such functionality, but it is under AGPL licence so cannot be used in my case...

For the time being, I will try acheive my needs using apache POI then convert the generated docx to pdf using opensagres/xdocreport (see: Trying to make simple PDF document with Apache poi)