Skip to content

set_toc does not correctly set y-positions #4484

Description

@chadlester

Description of the bug

doc.set_toc does not always properly set y-positions. In my example pdf, they will be off by 90 pts.

How to reproduce the bug

buggy_toc_positions.pdf

doc = fitz.open("buggy_toc_positions.pdf")
toc = [[1, 'Engine Fire In Flight', 0, 304.6222839355469]]
doc.set_toc(toc)
read_toc = doc.get_toc(simple=False)
desired_y_position = toc[0][3]
actual_y_position = read_toc[0][3]["to"][1]
if (desired_y_position != actual_y_position):
    print ("BUG FOUND!", desired_y_position, actual_y_position)
else:
    print ("Success!")

Output:
BUG FOUND! 304.6222839355469 394.62229

PyMuPDF version

1.25.5

Operating system

MacOS

Python version

3.13

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions