You are combining the files by attaching them to a new PDF which only has a cover page, and making this file a Portfolio as Adobe calls it:
PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, null, af.fileName, af.documentData.data);
fs.addCollectionItem(item);
writer.addFileAttachment(fs);
Thus, your code is not one of the typical merge functions (using PdfCopy
or PdfWriter
with getImportedPage
; correct ones use PdfCopy
, fishy ones use PdfWriter
) which generate a single PDF containing all source pages as genuine document pages. Instead your code creates a single page document with other PDFs as attachments and some extra information making PDF viewers display the attached PDFs inline.
If you want to access the pages of these attached PDFs, you have to extract them again and open them in separate PdfReader
instances.
You can find more information on extracting PDF attachments in this answer.