Getting below exception while reading a PDF. It opens well in Acrobat reader. I read in another question that though its opened in acrobat its not necessary to open via iText because PDF contains an error and he recommends to fix the PDF. But the file is coming from the client and they are able to open Acrobat, so either I have to fix it or show the error or warning in Acrobat.
com.itextpdf.text.exceptions.InvalidPdfException: Rebuild failed: Error reading string at file pointer 10891; Original message: Error reading string at file pointer 10891
at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:655)
Excerpt of PDF file
%PDF-1.1
1 0 obj
<<
/Creator (Developer 2000)
/CreatorDate (
/Author (Oracle Reports)
/Producer (Oracle PDF driver)
/Title (con5010I412014141258.pdf)
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids 4 0 R
/Count 5 0 R
>>
endobj
7 0 obj
<</Length 8 0 R>>
stream
BT
It is actually a Invalid PDF. When I open the PDF in text editor I noticed that header has CreatorDate with out close bracket. I just added the close bracket with valid date like this CreatorDate (05 November 2014 17:50:24) then It works. I asked client to correct on their side
Edit the PDF in a text editor (notepad, notepad++, etc.) and simply add a closing parenthesis.
So the following line:
/CreatorDate (
Changes to:
/CreatorDate ()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With