2017-10-10 203 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

相關問題