Replies: 3 comments 6 replies
-
When updating an annotation with a tool that is different from the tool that created it, errors or unexpected results are to be expected in general - see here. Independently from this, there is some inconsistency in PyMuPDF's behavior as you have noticed: In any case, your creator software makes the annotation in a way such that everything is inside the specified rectangle, whereas the PyMuPDF update changes the rectangle such that 50% of the line width area is outside ... Can you please give me the annotation object details as created by your initial editor? Probably an out like |
Beta Was this translation helpful? Give feedback.
-
I did run this: doc = pymupdf.open(pth)
p1 = doc[0]
for annot in p1.annots():
print(annot.rect)
print(annot.border)
print(doc.xref_object(annot.xref))
annot.update() Terminal printout:
|
Beta Was this translation helpful? Give feedback.
-
To my main Question about the Border/Corner width... The method doc = pymupdf.open("tests/test.pdf")
page = doc[0]
xrefs = [annot.xref for annot in page.annots()]
for xref in xrefs:
annot = page.load_annot(xref)
colors = annot.colors
colors["stroke"] = [0, 1, 0]
annot.set_colors(colors)
annot.update()
xref_body = doc.xref_object(xref, compressed=True)
rd_el = _get_key("/RD", xref_body)
if rd_el:
xref_body = xref_body.replace(rd_el, "")
doc.update_object(xref, xref_body)
doc.save("tests/out.pdf")
doc.close() So far this works for me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I wanted to quickly ask why PyMuPDF behaves the way it does in the following example.
I added a rectangle as a note using my editor (to define a zone on my floor plan). Now I want to use PyMuPDF to add my "content" and save it. The problem I observe is that after calling
annot.update(),
the boundaries somehow change.See following images:

Rectangle (created in the editor)
After I run:
Image 2: (updated rectangle)

When I open the PDF, you can see that the "selection" frame does not match the one in the first image.
Additional:

Image 3:
Shows the behavior when I simply stretch the rectangle to the right in the editor. Then the "border" just jumps back.
It's hard for me to explain this more precisely.
Am I missing something about how to properly use the
annot.update()
method?But I also observe:
terminal printout:
But my definition is 10,10,100,100
Maybe some can drop a comment to understand this circumstance here and thx for your help!
BTW: I have the same behavior with PDFXchange and Ocular.
greets: ibbit
Beta Was this translation helpful? Give feedback.
All reactions