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

Function JM_get_annot_by_name

src/__init__.py:19617–19638  ·  view source on GitHub ↗

retrieve annot by name (/NM key)

(page, name)

Source from the content-addressed store, hash-verified

19615
19616
19617def 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
19641def JM_get_annot_id_list(page):

Callers 1

_load_annotMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…