I'm the author of the book about iText and in the context of this book, I've written an example that explains how to concatenate PDFs while preserving the bookmarks (aka the outline tree). You can find this example here. As you can see, you need the SimpleBookmark
object to extract the bookmarks from the existing documents. Make sure that you shift the page numbers, or your links will point at the wrong pages. Finally add the new ArrayList<HashMap<String, Object>>
to the PdfCopy
object using the setOutlines()
method.
Once again, we've found proof that reading documentation saves time ;-)