retrieve annot by name (/NM key)
(page, name)
| 19615 | |
| 19616 | |
| 19617 | def JM_get_annot_by_name(page, name): |
| 19618 | ''' |
| 19619 | retrieve annot by name (/NM key) |
| 19620 | ''' |
| 19621 | assert isinstance(page, mupdf.PdfPage) |
| 19622 | if not name: |
| 19623 | return |
| 19624 | found = 0 |
| 19625 | # loop thru MuPDF's internal annots and widget arrays |
| 19626 | annot = mupdf.pdf_first_annot(page) |
| 19627 | while 1: |
| 19628 | if not annot.m_internal: |
| 19629 | break |
| 19630 | |
| 19631 | response, len_ = mupdf.pdf_to_string(mupdf.pdf_dict_gets(mupdf.pdf_annot_obj(annot), "NM")) |
| 19632 | if name == response: |
| 19633 | found = 1 |
| 19634 | break |
| 19635 | annot = mupdf.pdf_next_annot(annot) |
| 19636 | if not found: |
| 19637 | raise Exception(f"'{name}' is not an annot of this page") |
| 19638 | return annot |
| 19639 | |
| 19640 | |
| 19641 | def JM_get_annot_id_list(page): |
no outgoing calls
no test coverage detected
searching dependent graphs…