Skip to content

Orientation of text fields and widgets differ when page rotation is 90° #496

@Papafelice

Description

@Papafelice

Description of the bug

When inserting a text box, the bouding rectangle remains in document coordinates when rotation = 90. However, when inserting a text widget, the bounding box is as seen on the screen but the text flow remains in document coordinates. It would be convenient, if the bounding box and textflow is as seen on the screen or at least both text items should behave the same.

Steps to reproduce

Code snippet:

import fitz         
doc = fitz.open()  
doc.insertPage(0)
page = doc[0]                         

rect1 = fitz.Rect(50,  50, 300, 100)
rect2 = fitz.Rect(50, 100, 300, 150)
rect3 = fitz.Rect(50, 150, 300, 200)
rect4 = fitz.Rect(50, 200, 300, 350)

text = """The quick brown fox jumps over the lazy dog.\nSeveral times..."""
page.insertTextbox(rect1, text, align = 0)
widget = fitz.Widget()
widget.rect = rect2
widget.field_type = fitz.PDF_WIDGET_TYPE_TEXT
widget.field_name = "Text1"
widget.field_value = text
page.addWidget(widget)
page.setRotation(90)
page.insertTextbox(rect3, text, align = 0)
widget.rect = rect4
page.addWidget(widget)
doc.save("out.pdf")
doc.close()

Open the file with a PDF Viewer that can edit fields.

Expected behavior

Either both elements should remain in page coordinates or (better) they should adopt to the screen view such that when you have a graphical display of a page and you select a rectangle with the mouse, the text is inserted as seen on the screen

Configuration

OS: Suse Tumblewheed Linux 5.6.4-1-default 64bit
Python: 3.8.2 64bit
PyMuPDF 1.16.18: Python bindings for the MuPDF 1.16.0 library.
Version date: 2020-04-22 14:00:00. Built for Python 3.8 on linux (64-bit). Installed with pip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions