-
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
As always: We need an example file to reproduce - not just a picture! |
Beta Was this translation helpful? Give feedback.
-
https://tfile.yj2025.com/pdf-processor/source/2024-04-02/mt_04_24024_0_812-wps.pdf |
Beta Was this translation helpful? Give feedback.
-
test code like this:
|
Beta Was this translation helpful? Give feedback.
-
get_url_content_retry can be replace with:
|
Beta Was this translation helpful? Give feedback.
-
This phenomenon also exists in version 1.24.1 |
Beta Was this translation helpful? Give feedback.
-
If you follow the documentation, things work correctly, see here: doc=fitz.open("test.pdf")
page=doc[0]
page.add_freetext_annot((50,100,150,200),text,rotate=90,text_color=(1,0,0))
'FreeText' annotation on page 0 of test.pdf
doc.ez_save("x.pdf") |
Beta Was this translation helpful? Give feedback.
-
Yes, if I add a annot at the agreed 90, the angle is correct, but the rotation of the original annot, obtained by xref, is -90. I would like to copy the annot as it is and use it in the new page, is there any way to correct the rotation obtained by xref? |
Beta Was this translation helpful? Give feedback.
-
found through pymupdf added after the rotation of the annotations, and then get the xref keys is rotate, then why other tools to add the annotations through the xref to get the rotation is -90, and then annot.rotation directly is -1? print(doc2.xref_get_keys(annot.xref)) way 1: page.add_freetext_annot((50,100,150,200),text,rotate=90,text_color=(1,0,0))
other tools way:
|
Beta Was this translation helpful? Give feedback.
-
All of the text above is oriented at 90 degrees, but the results are not the same.
output
|
Beta Was this translation helpful? Give feedback.
-
There are a number of alternatives how rotation of text in a FreeText annot can be achieved. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll look into line-dictionary. |
Beta Was this translation helpful? Give feedback.
There are a number of alternatives how rotation of text in a FreeText annot can be achieved.
The only definitive way to find the actual text rotation is by using text extraction in "dict" format. The dict key "dir" in the line dictionary gives you the text orientation.
Use this (consult the documentation!) to compute the rotation angle to use when recreating the annot somewhere else.
In your case, you will find
"dir":(0,-1)
in the line dctionary.