Page 11 has the wrong parent. It is 13881 but should be 90.


However a similar problem is in the source file. Parent points to 98 but should be 18564.


Tilman

Am 27.01.2021 um 12:41 schrieb Hesham Gneady:
Hello,

I am trying to add a blank page to a PDF file after specific page, using
PDFBox 2.0.21. For some PDFs it works fine, but for others when opening the
PDF using Adobe Reader or any reader the PDF becomes totally ruined. Many
pages have 0 dimensions. Zooming becomes wrong, and I get error "There was a
problem reading this document (14)".

Here is my code:

PDDocument pdfDocument = PDDocument.load( pdfFile );

PDPageTree rootPages = pdfDocument.getPages();

PDPage blankPage = new PDPage( PDRectangle.A4 );

rootPages.insertAfter( blankPage, pdfDocument.getPage( 2 ) );

pdfDocument.save( pdfFile.getAbsoluteFile() );

pdfDocument.close();

As a sample PDF, here is an original PDF file:

https://dl.dropboxusercontent.com/s/dj5rzy7f47k8e3f/Eclipse.pdf?dl=0
<https://www.dropbox.com/s/dj5rzy7f47k8e3f/Eclipse.pdf?dl=0>

Then after appending a blank page to it:

https://dl.dropboxusercontent.com/s/q5qgj24bu9nves2/Eclipse%20-After%20addin
g%20page.pdf?dl=0
<https://www.dropbox.com/s/q5qgj24bu9nves2/Eclipse%20-After%20adding%20page.
pdf?dl=0>

And here is the error message when viewing the PDF:

https://dl.dropboxusercontent.com/s/2peynubfwwgeeu7/Eclipse%20-After%20addin
g%20page%20-%20Error.jpg?dl=0

I have the same problem for more than 1 PDF. Is there a way to fix that?

Best regards,

Hesham



Reply via email to