[英]Error in PDF root object
This PDF root object will get Adobe Reader to fail.此 PDF 根 object 将使 Adobe Reader 失败。 Other PDF readers like Foxit, Nuance, Evince, SumatraPDF will open the PDF file without problems.
其他 PDF 阅读器,如 Foxit、Nuance、Evince、SumatraPDF 将毫无问题地打开 PDF 文件。 The problem is /Dests which reguires an indirect object (PDF reference).
问题是 /Dests 需要间接 object(PDF 参考)。 Deleting the /Dests << >> will get Adobe Reader to open the file, but fail on printing.
删除 /Dests << >> 将使 Adobe Reader 打开文件,但打印失败。 All the other readers work OK without the /Dests.
没有/Dests,所有其他阅读器都可以正常工作。 Any ideas how to correct the syntax in the following root object example?
任何想法如何更正以下根 object 示例中的语法?
17 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/Outlines 15 0 R
/PageMode /UseOutlines
/Dests <<
/__WKANCHOR_2 8 0 R
/#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83 9 0 R
>>
>>
endobj
OK, found a few spare minutes...好的,找到了几分钟的空闲时间...
So the first thing I noticed is that * all other readers indeed may open the file (I only tested a few).所以我注意到的第一件事是 *所有其他读者确实可以打开文件(我只测试了几个)。 But these do spit out lots and lots of warnings and error messages... (Try Ghostscript:
gs virkerikke.pdf
, or try evince...) There is at least a damaged xref
table in the PDF as well (or at least this is one of the complaints).但是这些确实会吐出很多警告和错误消息...(尝试 Ghostscript:
gs virkerikke.pdf
,或尝试 evince...) PDF 中至少有一个损坏的xref
表(或至少这个是投诉之一)。
xpdf
complains: xpdf
抱怨:[....]
Error: Invalid XRef entry
Error: Invalid XRef entry
Error: Invalid XRef entry
Error (157): Unterminated string
Error (159): End of file inside dictionary
gv
complains: gv
抱怨:Warning: translation table syntax error: Unknown keysym name: apLineDel
Warning: ... found while parsing '<Key>apLineDel: GV_Page(page+5) '
Warning: String to TranslationTable conversion encountered errors
evince
complains: evince
抱怨:[....]
Error: Invalid XRef entry
Error: Invalid XRef entry
Error: Invalid XRef entry
Error (157): Unterminated string
Error (159): End of file inside dictionary
Error (157): Unterminated string
Error (159): End of file inside dictionary
Error (157): Unterminated string
Error (159): End of file inside dictionary
[....]
Error (1918): Unterminated string
Error (1920): End of file inside dictionary
gs
complains: gs
抱怨:**** Warning: File has a corrupted %%EOF marker, or garbage after %%EOF.
mupdf
complains: mupdf
抱怨:+ pdf/pdf_xref.c:60: pdf_read_start_xref(): cannot find startxref
| pdf/pdf_xref.c:477: pdf_load_xref(): cannot read startxref
\ pdf/pdf_xref.c:532: pdf_open_xref_with_stream(): trying to repair
warning: ignoring invalid character in hex string: '!'
warning: ignoring invalid character in hex string: 'O'
warning: ignoring invalid character in hex string: 'T'
warning: ignoring invalid character in hex string: 'Y'
[....]
qpdf --qdf
complains: qpdf --qdf
抱怨:virkerikke.pdf (object 17 0, file position 2234): null character not allowed in name token
OK, now opening this crappy file in a text editor, trying to repair it.好的,现在在文本编辑器中打开这个糟糕的文件,尝试修复它。 What I find is this that this file (32746 Bytes in size) has some serious syntax problems:
我发现这个文件(大小为 32746 字节)有一些严重的语法问题:
%%EOF
: There is a complete and syntax-correct HTML-File glued to the PDF after its %%EOF
marker with the title "Wkhtmltopdf - Teknisk regelverk" . %%EOF
之后的垃圾:在 PDF 的%%EOF
标记之后,有一个完整且语法正确的 HTML 文件,其标题为"Wkhtmltopdf - Teknisk regelverk" 。 Its size is 11878 Bytes./#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83
./#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83
。 It appears 2x in this file.#00
which is the PDF representation for a nul
character... the use of which is illegal for name tokens in PDF.) Replace that name token with another (phantasy) one of exactly the same length (on both occurrences). I did choose /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
. Save the edited file.#00
是一个nul
字符的 PDF 表示形式......对于 PDF 中的名称标记,使用它是非法的。)用另一个(幻想)长度完全相同的名称标记替换该名称标记(两次出现)。我做了选择/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
保存编辑的文件。 Now even Acrobat/Adobe Readers will open this repaired file without complaining.现在,即使是 Acrobat/Adobe Readers 也可以毫无怨言地打开这个修复过的文件。 Also, the 'other readers' will work now better with this file, spitting out less warnings and now being able to identify some metadata (such as creation date and producer == wkhtmltopdf) which they were unable to get to for the original file.
此外, “其他阅读器”现在可以更好地使用此文件,发出更少的警告,并且现在能够识别他们无法获取原始文件的一些元数据(例如创建日期和生产者 == wkhtmltopdf)。
/Dests
is supposed to be a dictionary (pairs of /Key value
) containing names (Keys) and corresponding destinations (values). /Dests
应该是包含名称(键)和相应目的地(值)的字典( /Key value
对)。 The /Dests
keyword first appeared in PDF 1.1. /Dests
关键字首次出现在 PDF 1.1 中。
PDF 1.1 allowed for the keys only to be a name object. PDF 1.1 允许键仅是名称 object。 PDF 1.2 allowed for keys to also be byte strings.
PDF 1.2 允许键也是字节字符串。
So which PDF version does your file claim to be?那么您的文件声称是哪个 PDF 版本?
From the spec for PDF 1.7 ("ISO 32000-1"), describing the meaning of /Dests
:来自 PDF 1.7(“ISO 32000-1”)的规范,描述了
/Dests
的含义:
In PDF 1.1, the correspondence between name objects and destinations shall be defined by the Dests entry in the document catalogue (see 7.7.2, “Document Catalog”).
在 PDF 1.1 中,名称对象和目的地之间的对应关系应由文档目录中的 Dests 条目定义(参见 7.7.2,“文档目录”)。 The value of this entry shall be a dictionary in which each key is a destination name and the corresponding value is either an array defining the destination, using the syntax shown in Table 151, or a dictionary with a D entry whose value is such an array.
这个条目的值应该是一个字典,其中每个键是一个目的地名称,并且对应的值是一个定义目的地的数组,使用表 151 中所示的语法,或者一个具有 D 条目的字典,其值是这样一个数组.
Seems pretty straightforward.看起来很简单。 Move the dests array into its own object.
将 dests 数组移动到它自己的 object 中。
Rather than而不是
17 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/Outlines 15 0 R
/PageMode /UseOutlines
/Dests <<
/__WKANCHOR_2 8 0 R
/#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83 9 0 R
>>
>>
endobj
you should instead have:你应该有:
17 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/Outlines 15 0 R
/PageMode /UseOutlines
/Dests 1234 0 R
>>
endobj
1234 0 obj
<</__WKANCHOR_2 8 0 R/#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83 9 0 R>>
endobj
The object number is going to be something pseudorandom. object 数字将是伪随机数。
And how to move the dest array out of the root into its own object going to be entirely dependent on what PDF software you're using.以及如何将 dest 数组从根目录移到它自己的 object 将完全取决于您使用的 PDF 软件。 "A Hex Editor" is an option, but then you're over on SuperUser instead of here on StackOverflow... technically.
“十六进制编辑器”是一个选项,但是从技术上讲,您在 SuperUser 上而不是在 StackOverflow 上。 I suspect you might get a mulligan on that one.
我怀疑你可能会在那个上得到一个调度。 I'd let it slide myself.
我会让它自己滑动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.