Skip to content

PDF page is mirrored, origin is at bottom-left #4415

Closed
@perkma

Description

@perkma

Maybe someone can tell me, why the attached PDF-file is mirrored along the horizontal axis and the origin is bottom right.
The rotation is 0 and the rotation matrix is the identity-matrix.
The PDF is exported from software Rhino and I can not figure out where this transformation comes from.
I know that the problem is related to the PDF file. If I use files from other sources than Rhino everything works fine.

I used the code from issue #4378 to add some text at top left position:

import pymupdf

# code from https://github.com/pymupdf/PyMuPDF/issues/4378

doc = pymupdf.open("test.pdf")
page = doc[0]
rot = page.rotation
orig = pymupdf.Point(100, 100)  # apparent insertion point
text = "Text at Top-Left"
mrot = page.derotation_matrix  # matrix anihilating page rotation
page.insert_text(orig * mrot, text, fontsize=60, rotate=rot)
doc.ez_save("output.pdf")

Image

The input file is test.pdf.
test.pdf

The result is output.pdf.

output.pdf

Any help is appreciated.

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