Skip to content

insert text to a landscape page, the text is invisible or in wrong position by the coordinate is wrong #4378

Closed
@sa168

Description

@sa168

I want to insert text into an existing PDF file. When the page orientation is landscape, text intended for the top-left corner appears on the right side of the page, and the text direction changes from left-to-right to top-to-bottom. I tried applying the solution mentioned in #2721 (multiplying the original coordinates by page.rotation_matrix), but now the text I'm trying to insert is completely invisible on the page.

Below is the test code I used:

`import pymupdf as fitz

doc = fitz.open("1.pdf")
page = doc[0]
x_user, y_user = 100, 100

pdf_point = fitz.Point(x_user, y_user) #* page.rotation_matrix

page.insert_text(pdf_point, "Text at top-left", fontsize=60)

doc.save("output.pdf")`

A3 landscape.pdf

output.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    not a bugnot a bug / user error / unable to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions