阅读 PDF 时获得以下异常。它在 Acrobat 阅读器中打开得很好。我在另一个问题中读到,虽然它在 acrobat 中打开,但没有必要通过 iText 打开,因为 PDF 包含错误,他建议修复 PDF。但是该文件来自客户端并且他们能够打开 Acrobat,所以要么我必须修复它,要么在 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)
Run Code Online (Sandbox Code Playgroud)
PDF文件摘录
%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
Run Code Online (Sandbox Code Playgroud)
它实际上是一个无效的 PDF。当我在文本编辑器中打开 PDF 时,我注意到标题的 CreatorDate 没有右括号。我刚刚添加了有效日期的右括号,例如 CreatorDate (05 November 2014 17:50:24) 然后它起作用了。我要求客户纠正他们的立场