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,
)
| 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 |