I don't do freelancing and I never looked at the merge code so I'm hardly your guy, but maybe somebody else will come forward.

This workaround code worked for me with the files in the JIRA issue:

PDDocument doc1 = PDDocument.loadNonSeq(new File("part1.pdf"), null); PDDocument doc2 = PDDocument.loadNonSeq(new File("part2.pdf"), null);
        PDDocument doc3 = new PDDocument();
        doc3.importPage(doc1.getPage(0));
        doc3.importPage(doc1.getPage(1));
        doc3.importPage(doc2.getPage(0));
        doc3.importPage(doc2.getPage(1));
for (PDPage pdPage : (List<PDPage>) doc3.getDocumentCatalog().getAllPages())
        {
            if (pdPage.getMediaBox() == null)
                pdPage.setMediaBox(PDPage.PAGE_SIZE_A4);
        }
        doc3.save(new File("res.pdf"));
        doc1.close();
        doc2.close();
        doc3.close();


The only mystery (to me) is why I had to set the media box. Without that, the page is too small (probably US letter)


Tilman

Am 07.07.2014 11:31, schrieb Aleksander Blomskøld:
Hi,

We're using PDFBox for PDF validation and PDF merging in a backend
invoicing system. It's working pretty well for most of the time, but right
now we're having some unhappy customers because of
https://issues.apache.org/jira/browse/PDFBOX-1533.

As it's important for us to have this fixed pretty soon, we're wondering if
anyone of you would be willing to fix this issue for pay. If so, please
contact me so we can work out the details.


Regards,

Aleksander Blomskøld


Reply via email to