Apache PDFBox merge a single PDF with an Adobe PDF Portfolio

187 views Asked by At

I have the following issue. I have a normal PDF and a Adobe PDF Portfolio, aka a PDF with many PDF files in it. Now I would like to merge the "normal" PDF with the PDF Portfolio using the merge option of Apache PDFBox. Problem is, it only merges the first file of the PDF Portfolio and ignores the rest. I am using the latest version of Apache PDFBox (3.0.1). Is it in someway possible to merge all the files in a PDF Portfolio with another, normal PDF without changing or extracting the files of the portfolio? I am also open to solutions that require another Java based PDF merge tool.

I tried merging a PDF Portfolio and a normal PDF with Apache PDFBox 3.0.1 using the following command on the CMD:

java -jar C:\Users\user\Downloads\pdfbox-app-3.0.1.jar merge -i=C:\Users\user\Downloads\pdf_portfolio.pdf -i=C:\Users\user\Downloads\normal_pdf.pdf -o=C:\Users\user\Downloads\new.pdf

The output is a PDF file that contains the full "normal_pdf" and the first file of the PDF portfolio. What in wanted to happen was, that all the files in the PDF Portfolio get merged with the normal PDF.

1

There are 1 answers

0
Jonas Baur On BEST ANSWER

I was able to solve this problem by extracting all the attachements of an PDF Portfolio if they are of type PDF. Then I merge all those extracted PDFs into a new, single PDF and merge that new PDF then with the other, normal PDF I wanted to merge with in the beginning. Thanks to @KJ for helping me with the solution!