1

I am working on a program that produces PDF files. My sample code produced an incremental updated PDF with XRef stream. Adobe Reader appears to believe that there are some problems with this simple PDF file. However other PDF readers like poppler and chrome have no issue with it. Can someone help me with this?

The file is listed below, or you can download at https://github.com/monstervia/pdfsign/blob/main/sample-update.pdf

%PDF-1.6
%âãÏÓ
1 0 obj
<</Type/Catalog/Pages 2 0 R>>
endobj
2 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<<>>/MediaBox[0 0 612 792]>>
endobj
xref
0 4
0000000000 65535 f 
0000000015 00000 n 
0000000060 00000 n 
0000000111 00000 n 
trailer<</Size 4/Root 1 0 R>>
startxref
190
%%EOF
6 0 obj
<</Type/ObjStm/N 2/First 9/Length 235>>
stream
2 0 5 36
<</Type/Pages/Kids[5 0 R]/Count 1>>
<</Type/Page/MediaBox[0 0 612 792]/Contents 4 0 R/Resources<</ProcSet[/PDF/Text]/Font<</F1<</Type/Font/Subtype/Type1/Name/F1/BaseFont/Helvetica/Encoding/WinAnsiEncoding>>>>>>/Parent 2 0 R>>

endstream
endobj
4 0 obj
<</Length 41>>
stream
BT /F1 15 Tf 72 720 Td (First Page) Tj ET
endstream
endobj
7 0 obj
<</Size 8/Prev 190/Root 1 0 R/ID[<52095740c7264561f0689d47606e10e2><52095740c7264561f0689d47606e10e2>]/Type/XRef/W[1 2 2]/Filter/ASCIIHexDecode/Index[0 1 2 6]/Length 106>>
stream
00 00 03 FF FF
02 00 06 00 00
00 00 00 00 01
01 02 7D 00 00
02 00 06 00 01
01 01 49 00 00
01 02 D6 00 00
>
endstream
endobj
startxref
726
%%EOF
cuteCAT
  • 2,251
  • 4
  • 25
  • 30
  • Adobe Reader expects pdfs with a cross reference table (or hybrid cross references) to be incrementally updated with a cross reference table (or hybrid cross references), not a pure cross reference stream. – mkl Dec 02 '20 at 08:25
  • Also see the Leonard Rosenthol quote in [this answer](https://stackoverflow.com/a/14964889/1729265). – mkl Dec 02 '20 at 08:50

1 Answers1

0

Thanks mkl. Based on his comment I finally figured out. Although the PDF standard does not forbid it, Adobe reader does not read a incrementally updated PDF with mixed cross reference types. So if the initial file has a cross reference table, the updated files must also use cross reference table. Cross reference stream can exist however, through the hybrid approach described in section 7.5.8.4.

cuteCAT
  • 2,251
  • 4
  • 25
  • 30