LibrePDF / OpenPDF

OpenPDF is a free Java library for creating and editing PDF files, with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository.
Other
3.41k stars 572 forks source link

Root object is missing or invalid #135

Open tekurusu opened 5 years ago

tekurusu commented 5 years ago

There seems to be a bug with recompiling some pdfs: after just using PdfReader and writing with PdfStamper, opening the resulting output in Adobe reader outputs "There was an error opening this document. The root object is missing or invalid."

Checking the resulting file, the root object was referencing a non-existent object in the pdf. Checked and it might be because the original pdf had three Catalog objects, while the resulting pdf had one only, and it was referenced by the Info object.

My initial fix was to check that if the Info object was a Catalog type, the Root object would be referencing it; this fix worked, but I am not so sure since I am very inexperienced with pdf manipulation. Here is the pull request but highly doubtful that it is a viable fix.

Some notes:

andreasrosdal commented 5 years ago

but highly doubtful that it is a viable fix.

Are you still highly doubtful that this is a viable fix? Why should it be accepted then?

andreasrosdal commented 5 years ago

For science and progress, here is how an AGPL project chose to solve this: https://github.com/itext/itextpdf/blob/develop/itext/src/main/java/com/itextpdf/text/pdf/PdfStamperImp.java#L487

asturio commented 4 months ago

Just wondering, if we should close this issue, as there is no example code to reproduce the error. Also without example code we can't check if this is still an issue.

asturio commented 2 months ago

Closing this issue, as there is no example PDF to investigate it. Also seems to be a problem of a particular PDF.

mkl-public commented 2 months ago

Considering Andreas' comment he appears to have had an idea what the issue was about.