Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF that renders in Chrome but not in Acrobat

Tags:

pdf

%PDF-1.7
4 0 obj
<</Type/ObjStm/N 3/First 14/Length 139>>
stream
1 0 2 41 3 76 <</Type/Catalog/Version/1.7/Pages 2 0 R>><</Type/Pages/Kids[3 0 R]/Count 1>><</Type/Page/MediaBox[0 0 200 200]/Parent 2 0 R>>
endstream
endobj
5 0 obj
<<
    /Root 1 0 R
    /ID[<7F1FE2C507E6DB4CB0787E660F2B0C65><2450E4E8FF5FC84380428886C0DD4C2F>]
    /Size 6
    /Index[1 5]
    /W[1 4 1]
    /Type/XRef
    /Length 68
    /Filter[/ASCIIHexDecode]
>>
stream
020000000400
020000000401
020000000402
010000000A00
01000000E500
endstream
endobj
startxref
229
%%EOF

The PDF above opens in Chrome (or Edge), but in Adobe Acrobat (Reader) it crashes. Ghostscript regards it as fine too. Note that it assumes CRLF for line breaks.

I read the parts of the PDF spec that are relevant for a basic PDF, and it seems that the above syntax follows it. Why doesn't Adobe like it?

Here is a link to the PDF. Notice how it opens in Chrome, but crashes in Adobe Acrobat. (This PDF uses LF for line breaks, and has a Resources dictionary on the page, based on the comments.)

like image 924
wezten Avatar asked Jun 18 '20 15:06

wezten


1 Answers

Acrobat has the following 2 quirks, both of which do not follow the specs:

  1. If the XRef Stream has a single filter, an array must not be used. So /Filter[/FlateDecode] won't work, and /Filter/FlateDecode will. This may apply to any Stream Object, not sure.
  2. An XRef Stream must use the FlateDecode filter. ASCIIHexDecode won't work. A predictor is not required.

Here is a link to the above PDF, fixed up for Acrobat.

like image 138
wezten Avatar answered Nov 19 '22 22:11

wezten