Skip to content

Outline (TOC) parsing bug #5044

Description

@kybos

Description of the bug

get_toc() returns inconsistent results for many of my docs (created with MasterPDF Editor).
Some (but not all) outlines are wrongly returned with kind=4 but without nameddest (and also a wrong page number).

Analysis shows that in the pdf source the structure of all outline items is identical. The only difference is that for the wrong items there is a "null" value in the corresponding /XYZ element. When "null" is manually changed to 0 in the pdf source, the get_toc output becomes correct.

How to reproduce the bug

Relevant snippets from the pdf source + get_toc output per line:

6 0 obj
<</A 73 0 R /C[ 0 0 0]/F 0/Title(Page 1)/Parent 74 0 R /Next 22 0 R >>
73 0 obj
<</S/GoTo/Type/Action/D[ 8 0 R /XYZ 0 842 0]>>

[1, 'Page 1', 1, {'color': (0.0, 0.0, 0.0), 'kind': 1, 'page': 0, 'to': Point(0.0, 0.0), 'xref': 6, 'zoom': 0.0}]


22 0 obj
<</A 58 0 R /C[ 0 0 0]/F 0/Title(Page 2)/Parent 74 0 R /Prev 6 0 R /Next 59 0 R >>
58 0 obj
<</S/GoTo/Type/Action/D[ 10 0 R /XYZ 0 null 1]>>

[1, 'Page 2', 3, {'color': (0.0, 0.0, 0.0), 'kind': 1, 'page': 2, 'to': Point(0.0, 841.8), 'xref': 22, 'zoom': 1.0}]


59 0 obj
<</A 68 0 R /C[ 0 0 0]/F 0/Title(Page 3)/Parent 74 0 R /Prev 22 0 R /Next 24 0 R >>
68 0 obj
<</D[ 15 0 R /XYZ 0 null 0]/S/GoTo/Type/Action>>

[1, 'Page 3', 8, {'color': (0.0, 0.0, 0.0), 'kind': 4, 'page': '8', 'xref': 59, 'zoom': 0.0}]


24 0 obj
<</A 60 0 R /C[ 0 0 0]/F 0/Title(Page 4)/Parent 74 0 R /Prev 59 0 R /Next 7 0 R >>
60 0 obj
<</D[ 17 0 R /XYZ 0 null 0]/S/GoTo/Type/Action>>

[1, 'Page 4', 10, {'color': (0.0, 0.0, 0.0), 'kind': 4, 'page': '10', 'xref': 24, 'zoom': 0.0}]


7 0 obj
<</A 71 0 R /C[ 0 0 0]/F 0/Title(Page 5)/Parent 74 0 R /Prev 24 0 R >>
71 0 obj
<</S/GoTo/Type/Action/D[ 19 0 R /XYZ 0 783 0]>>

[1, 'Page 5', 12, {'color': (0.0, 0.0, 0.0), 'kind': 1, 'page': 11, 'to': Point(0.0, 2.4420167), 'xref': 7, 'zoom': 0.0}]

PyMuPDF version

1.28.0

Operating system

Linux

Python version

3.14

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions