This PDF root object will get Adobe Reader to fail. Other PDF readers like Foxit, Nuance, Evince, SumatraPDF will open the PDF file without problems. The problem is /Dests which reguires an indirect object (PDF reference). Deleting the /Dests << >> will get Adobe Reader to open the file, but fail on printing. All the other readers work OK without the /Dests. Any ideas how to correct the syntax in the following root object example?
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
/Dests
is supposed to be a dictionary (pairs of/Key value
) containing names (Keys) and corresponding destinations (values). The/Dests
keyword first appeared in PDF 1.1.PDF 1.1 allowed for the keys only to be a name object. PDF 1.2 allowed for keys to also be byte strings.
So which PDF version does your file claim to be?
From the spec for PDF 1.7 ("ISO 32000-1"), describing the meaning of
/Dests
: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 damagedxref
table in the PDF as well (or at least this is one of the complaints).xpdf
complains:gv
complains:evince
complains:gs
complains:mupdf
complains:qpdf --qdf
complains: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:
%%EOF
: There is a complete and syntax-correct HTML-File glued to the PDF after its%%EOF
marker with the title "Wkhtmltopdf - Teknisk regelverk". Its size is 11878 Bytes. Delete this part, and you'll have a 'better' PDF with a size of only 20868 Bytes left... though Acrobat/Adobe Reader still doesn't open it after you saved the edited file./#8d#c2#ca#ebs#e4#60#00#9e#97l#b9#80#1b#cb#86sQR#83
. It appears 2x in this file. Already in my first comments I told you that this key didn't look trustworthy to me, because it contains only very few ASCII characters, but lots of binary Bytes (using their hexadecimal representation. (What I had overlooked was that it even contained a#00
which is the PDF representation for anul
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.Now even Acrobat/Adobe Readers will open this repaired file without complaining. 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.
Seems pretty straightforward. Move the dests array into its own object.
Rather than
you should instead have:
The object number is going to be something pseudorandom.
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. "A Hex Editor" is an option, but then you're over on SuperUser instead of here on StackOverflow... technically. I suspect you might get a mulligan on that one. I'd let it slide myself.