doc.set_toc does not always properly set y-positions. In my example pdf, they will be off by 90 pts.
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!")
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
Output:
BUG FOUND! 304.6222839355469 394.62229PyMuPDF version
1.25.5
Operating system
MacOS
Python version
3.13