| 582 | # |
| 583 | |
| 584 | class Annot: |
| 585 | |
| 586 | def __init__(self, annot): |
| 587 | assert isinstance( annot, mupdf.PdfAnnot) |
| 588 | self.this = annot |
| 589 | |
| 590 | def __repr__(self): |
| 591 | parent = getattr(self, 'parent', '<>') |
| 592 | return f"'{self.type[1]}' annotation on {parent}" |
| 593 | |
| 594 | def __str__(self): |
| 595 | return self.__repr__() |
| 596 | |
| 597 | def _erase(self): |
| 598 | if getattr(self, "thisown", False): |
| 599 | self.thisown = False |
| 600 | |
| 601 | def _get_redact_values(self): |
| 602 | annot = self.this |
| 603 | if mupdf.pdf_annot_type(annot) != mupdf.PDF_ANNOT_REDACT: |
| 604 | return |
| 605 | |
| 606 | values = dict() |
| 607 | try: |
| 608 | obj = mupdf.pdf_dict_gets(mupdf.pdf_annot_obj(annot), "RO") |
| 609 | if obj.m_internal: |
| 610 | message_warning("Ignoring redaction key '/RO'.") |
| 611 | xref = mupdf.pdf_to_num(obj) |
| 612 | values[dictkey_xref] = xref |
| 613 | obj = mupdf.pdf_dict_gets(mupdf.pdf_annot_obj(annot), "OverlayText") |
| 614 | if obj.m_internal: |
| 615 | text = mupdf.pdf_to_text_string(obj) |
| 616 | values[dictkey_text] = JM_UnicodeFromStr(text) |
| 617 | else: |
| 618 | values[dictkey_text] = '' |
| 619 | obj = mupdf.pdf_dict_get(mupdf.pdf_annot_obj(annot), PDF_NAME('Q')) |
| 620 | align = 0 |
| 621 | if obj.m_internal: |
| 622 | align = mupdf.pdf_to_int(obj) |
| 623 | values[dictkey_align] = align |
| 624 | except Exception: |
| 625 | if g_exceptions_verbose: exception_info() |
| 626 | return |
| 627 | val = values |
| 628 | |
| 629 | if not val: |
| 630 | return val |
| 631 | val["rect"] = self.rect |
| 632 | text_color, fontname, fontsize = TOOLS._parse_da(self) |
| 633 | val["text_color"] = text_color |
| 634 | val["fontname"] = fontname |
| 635 | val["fontsize"] = fontsize |
| 636 | fill = self.colors["fill"] |
| 637 | val["fill"] = fill |
| 638 | return val |
| 639 | |
| 640 | def _getAP(self): |
| 641 | if g_use_extra: |
no outgoing calls
no test coverage detected
searching dependent graphs…