PDFKit's PDFOutline creates fundamentally flawed PDF syntax when it creates outlines ("Bookmarks") in a PDF document.
A PDF document is created with three outlines: "Page 1", "Page 2" and "Page 3". Each is a child of the former, so "Page 3" is a child of "Page 2", and "Page 2" is a child of "Page 1".
PDFKit produces flawed PDF syntax, with duplicate entries for each bookmark, missing sibling links, and a convoluted Parent > Child relationship.
3 0 obj
<< /Type /Pages /Parent 45 0 R /Count 8 /Kids [ 2 0 R 6 0 R 9 0 R 12 0 R 15 0 R
18 0 R 21 0 R 24 0 R ] >>
endobj
28 0 obj
<< /Type /Pages /Parent 45 0 R /Count 3 /Kids [ 27 0 R 31 0 R 34 0 R ] >>
endobj
45 0 obj
<< /Type /Pages /MediaBox [0 0 612 792] /Count 11 /Kids [ 3 0 R 28 0 R ] >>
endobj
46 0 obj
<< /Type /Catalog /Outlines 1 0 R /Pages 45 0 R >>
endobj
1 0 obj
<< /First 47 0 R /Last 48 0 R >>
endobj
48 0 obj
<< /Last 49 0 R /Count -1 /First 50 0 R /Title (Page 1) /Dest [ 2 0 R /XYZ
0 841.88 null ] /Parent 51 0 R >>
endobj
51 0 obj
<< >>
endobj
50 0 obj
<< /Last 52 0 R /Count -1 /First 53 0 R /Title (Page 2) /Dest [ 6 0 R /XYZ
0 841.88 null ] /Parent 51 0 R >>
endobj
53 0 obj
<< /Dest [ 9 0 R /XYZ 0 841.88 null ] /Count 0 /Title (Page 3) /Parent 51 0 R
>>
endobj
52 0 obj
<< /Dest [ 9 0 R /XYZ 0 841.88 null ] /Count 0 /Title (Page 3) /Parent 51 0 R
>>
endobj
49 0 obj
<< /Last 52 0 R /Count -1 /First 53 0 R /Title (Page 2) /Dest [ 6 0 R /XYZ
0 841.88 null ] /Parent 51 0 R >>
endobj
47 0 obj
<< /Last 49 0 R /Count -1 /First 50 0 R /Title (Page 1) /Dest [ 2 0 R /XYZ
0 841.88 null ] /Parent 51 0 R >>
endobj(The Parent of all the outline objects is given as object 51, which is blank. The First/Last objects don't link correctly to the expected hierarchy, etc, etc.)
Acrobat preflight will flag this as a syntax error, though the bookmarks do largely function in most viewers.
Preview doesn't show the top-level outline, though that might relate to FB4013726, filed in 2018.
I have shown the created syntax to ChatGPT, which also confirmed that the syntax does not conform to the expected PDF spec:
This isn’t simply a matter of PDFKit choosing an unnecessarily elaborate but valid representation. There are genuine structural problems:
The top-level Page 1 object’s /Parent does not point to the /Outlines dictionary.
The child objects’ /Parent does not point to their actual containing outline.
There are duplicate outline objects for Page 1, Page 2 and Page 3.
The required sibling Prev/Next chains are absent.
The /First//Last relationships don’t correspond cleanly to the claimed hierarchy.
The errors are entirely reproducible in any PDFOutlines created by PDFKit.
I have filed this as FB25328043.
... and in 2021 as FB8960602.
... and in 2019 as FB5313583.
2
0
337