Skip to content

bug: inserting rotated pages to another document messes up link coordinates #4958

@mahlzahn

Description

@mahlzahn

Description of the bug

Copying pages togther with links from one document to another leads to wrong coordinates in the copied document, see reproducer below.

How to reproduce the bug

import pymupdf

document = pymupdf.Document()
document.new_page()
document[0].set_rotation(90)
document[0].insert_link({'kind': 2, 'from': pymupdf.Rect(10, 20, 40, 60), 'uri': 'https://example.org'})

document_copy = pymupdf.Document()
document_copy.insert_pdf(document, links=True)

print('orig:', *(l['from'] for l in document[0].get_links()))
print('copy:', *(l['from'] for l in document_copy[0].get_links()))

prints

orig: Rect(782.0, 10.0, 822.0, 40.0)
copy: Rect(802.0, 782.0, 832.0, 822.0)

PyMuPDF version

1.27.2

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