MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / update

Method update

src/__init__.py:1589–1840  ·  view source on GitHub ↗

Update annot appearance. Notes: Depending on the annot type, some parameters make no sense, while others are only available in this method to achieve the desired result. This is especially true for 'FreeText' annots. Args: blend_mode:

(self,
            blend_mode: OptStr =None,
            opacity: OptFloat =None,
            fontsize: float =0,
            fontname: OptStr =None,
            text_color: OptSeq =None,
            border_color: OptSeq =None,
            fill_color: OptSeq =None,
            cross_out: bool =True,
            rotate: int =-1,
            )

Source from the content-addressed store, hash-verified

1587 return (type_, c, it)
1588
1589 def update(self,
1590 blend_mode: OptStr =None,
1591 opacity: OptFloat =None,
1592 fontsize: float =0,
1593 fontname: OptStr =None,
1594 text_color: OptSeq =None,
1595 border_color: OptSeq =None,
1596 fill_color: OptSeq =None,
1597 cross_out: bool =True,
1598 rotate: int =-1,
1599 ):
1600 """Update annot appearance.
1601
1602 Notes:
1603 Depending on the annot type, some parameters make no sense,
1604 while others are only available in this method to achieve the
1605 desired result. This is especially true for 'FreeText' annots.
1606 Args:
1607 blend_mode: set the blend mode, all annotations.
1608 opacity: set the opacity, all annotations.
1609 fontsize: set fontsize, 'FreeText' only.
1610 fontname: set the font, 'FreeText' only.
1611 border_color: set border color, 'FreeText' only.
1612 text_color: set text color, 'FreeText' only.
1613 fill_color: set fill color, all annotations.
1614 cross_out: draw diagonal lines, 'Redact' only.
1615 rotate: set rotation, 'FreeText' and some others.
1616 """
1617 annot_obj = mupdf.pdf_annot_obj(self.this)
1618
1619 if border_color:
1620 is_rich_text = mupdf.pdf_dict_get(annot_obj, PDF_NAME("RC"))
1621 if not is_rich_text:
1622 raise ValueError("cannot set border_color if rich_text is False")
1623 Annot.update_timing_test()
1624 CheckParent(self)
1625 def color_string(cs, code):
1626 """Return valid PDF color operator for a given color sequence.
1627 """
1628 cc = ColorCode(cs, code)
1629 if not cc:
1630 return b""
1631 return (cc + "\n").encode()
1632
1633 annot_type = self.type[0] # get the annot type
1634
1635 dt = self.border.get("dashes", None) # get the dashes spec
1636 bwidth = self.border.get("width", -1) # get border line width
1637 stroke = self.colors["stroke"] # get the stroke color
1638 if fill_color is not None:
1639 fill = fill_color
1640 else:
1641 fill = self.colors["fill"]
1642 rect = None # self.rect # prevent MuPDF fiddling with it
1643 apnmat = self.apn_matrix # prevent MuPDF fiddling with it
1644 if rotate != -1: # sanitize rotation value
1645 while rotate < 0:
1646 rotate += 360

Callers 15

runFunction · 0.45
getLinkDictFunction · 0.45
set_markinfoMethod · 0.45
add_widgetMethod · 0.45
__init__Method · 0.45
remove_rotationMethod · 0.45
chars_to_textmapFunction · 0.45
rect_to_edgesFunction · 0.45
test_2333Function · 0.45
test_2391Function · 0.45
test_4004Function · 0.45
test_4055Function · 0.45

Calls 15

_update_appearanceMethod · 0.95
_getAPMethod · 0.95
_setAPMethod · 0.95
get_parentMethod · 0.95
set_rectMethod · 0.95
set_apn_matrixMethod · 0.95
PDF_NAMEFunction · 0.85
CheckParentFunction · 0.85
CheckColorFunction · 0.85
JM_make_annot_DAFunction · 0.85
_format_gFunction · 0.85
PointClass · 0.85

Tested by 15

test_2333Function · 0.36
test_2391Function · 0.36
test_4004Function · 0.36
test_4055Function · 0.36
test_4505Function · 0.36
test_caretFunction · 0.36
test_freetextFunction · 0.36
test_polylineFunction · 0.36
test_lineFunction · 0.36
test_redact1Function · 0.36
test_4254Function · 0.36
test_richtextFunction · 0.36