com.itextpdf.text.exceptions.InvalidPdfException:重建失败:读取文件指针处的字符串时出错(com.itextpdf.text.exceptions.InvalidPdfException: Rebuild failed: Error reading string at file pointer)

在阅读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)
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
<>
stream
BT

有什么办法可以向客户表明PDF有错误吗? 通过Acrobat或其他软件而不是Java异常。

有没有办法解决这个错误并继续? 我们遇到了类似的安全PDF问题,我们解锁了。 请建议

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
<>
stream
BT
Is there any way I can show the client that the PDF has error? either via Acrobat or some other software rather Java exception.
Is there way to go around this error and proceed? We faced similar issues for secured PDF and we did unlock. Please suggest

更新时间:2020-06-28 22:06

最满意答案

它实际上是一个无效的PDF。 当我在文本编辑器中打开PDF时,我注意到标题的CreatorDate没有括号。 我刚刚添加了有效日期的近距离括号,比如这个CreatorDate(2014年11月5日17:50:24),然后就可以了。 我请客户纠正他们的一面

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

2015-02-24