6
%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.)

wezten
  • 2,126
  • 3
  • 25
  • 48
  • Please post PDFs (also) as binary downloads, not (only) as text dumps. – mkl Jun 18 '20 at 16:43
  • @mkl Added a link to the binary. – wezten Jun 18 '20 at 20:32
  • I'm not about to count offsets, but I can tell you that your file is missing a "Resources" dictionary. This is required either at the "Page" level, or in case of using inheritance at the "Pages" level. Whether this is why Acrobat is refusing your file I have no idea. – David van Driessche Jun 19 '20 at 09:52
  • 1
    Additionally the cross references do not have entries for 0..Size-1 but merely 1..Size-1. But adding an empty **Resources** dictionary and adding a 0 entry still don't make Adobe accept the file. – mkl Jun 19 '20 at 13:27
  • @DavidvanDriessche I tried adding an empty Resources dictionary, and updating the offsets, but it didn't help. Lmk if you'd like the PDF with it in. – wezten Jun 19 '20 at 15:17
  • @mkl I updated my link to include a Resources dictionary. I added a bounty. `Cross-reference streams` don't need an object 0, that is only required for a `Cross-reference table`, but thanks for trying these points. – wezten Jun 20 '20 at 19:35
  • *"Cross-reference streams don't need an object 0, that is only required for a Cross-reference table,"* - are you sure about that? The pdf specification is not as precise as one wants it to be. In particular Adobe products follow their own interpretations (from the pre-ISO-specification times)... – mkl Jun 20 '20 at 20:53

1 Answers1

6

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.

wezten
  • 2,126
  • 3
  • 25
  • 48