merge documents

I am merging multiple PDFs together into one PDF and I need to build bookmarks for the final PDF. For example, I have three PDFs: doc1.pdf, doc2.pdf and doc3.pdf, doc1 and doc2 belong to Group1, doc3 belongs to Group2. I need to merge them and have to build nested bookmarks for the resulting PDFs.
This example was originally written in answer to the question How to merge PDFs and add bookmarks? for iText5. The code here is a direct port from the iText5 code. Merging documents while maintaining bookmarks in iText7 is done automatically when using the PdfMerger object.
A series of examples that allow you to create reports using forms. These examples were used to answer questions such as: How to merge forms from different files into one PDF? How to merge documents correctly?
I need to create a TOC (not bookmarks) at the beginning of this document with clickable links to the first pages of each of the source PDFs.
I have two PDF files, each one in a ByteArrayOutputStream . I want to merge the two PDFs, and I want to use iText, but I don't understand how to do this because it seems that I need an InputStream (and I only have ByteArrayOutputStream s).
Many people search online for examples that show them how to merge / concatenate / assemble / join existing PDF document. Instead of reading the official documentation they end up using examples that are completely wrong. In this question, you'll see how NOT to merge documents ; in the answer, you'll discover how to merge documents correctly.
I am merging different PDF documents and I would like to add a link to an existing PDF that jumps to a coordinate on another page.
I create different PDFs and then concatenate them into a single PDF. My resulting PDF is a lot bigger than I had expected in file size. As it turns out, my PDF has a ton of duplicate fonts, and this is the reason why it's so big. I would like to create PDFs which only embed font information, not the full font.