2017-10-10 978 views
1

问题与报告的here相同。iText PDF失败并显示消息“Dictionary key endstream is not a name”

我已经采取this image和使用GraphicsMagick工具v1.3.26转换为this PDF(建于2017年7月4日):

gm convert itext_banner_InvalidPdfException.jpg itext_banner_InvalidPdfException.pdf

当我试着使用iText的v5.5.12读它,我得到的以下情况除外:

java -cp itextpdf-5.5.12.jar com.itextpdf.text.pdf.parser.PdfContentReaderTool itext_banner_InvalidPdfException.pdf 
com.itextpdf.text.exceptions.InvalidPdfException: Rebuild failed: Dictionary key endstream is not a name. at file pointer 1197; Original message: Dictionary key endstream is not a name. at file pointer 1197 
    at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:764) 
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:197) 
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:235) 
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:223) 
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:213) 
    at com.itextpdf.text.pdf.parser.PdfContentReaderTool.listContentStream(PdfContentReaderTool.java:200) 
    at com.itextpdf.text.pdf.parser.PdfContentReaderTool.main(PdfContentReaderTool.java:249) 

问题:

  • 给定PDF究竟有什么错误?看起来GhostScript中存在一个GraphicsMagick间接使用的问题。
  • 当我用iText RUPS v5.8.8打开它时,它不会打印任何警告控制台选项卡。这是否意味着它从iText RUPS的角度来看是有效的?

回答

1

您的PDF包含这个破碎的对象:

11 0 obj 
<< 

endstream 
endobj 

开幕<<endstream关闭。这不匹配。

如果该对象本来是一个单纯的字典,它应该是这个样子的:

11 0 obj 
<< 
    [a reasonable number of dictionary entries] 
>> 
endobj 

如果该对象本来是一个流,它应该是这个样子的:

11 0 obj 
<< 
    [a reasonable number of dictionary entries] 
>> 
stream 
    [stream data] 
endstream 
endobj 

顺便说一句,有问题的对象没有从PDF中的任何其他对象引用。因此,如果以部分模式在PdfReader中打开PDF,则问题将被忽略。

+0

你碰巧知道为什么iText RUPS不报告它?我认为它也是为此而设计的:恢复破碎的结构,但也要报告。 –

+0

我稍后再看看。但我不希望RUPS专门处理这个错误。 – mkl

相关问题