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

Function JM_add_annot_id

src/__init__.py:18561–18579  ·  view source on GitHub ↗

Add a unique /NM key to an annotation or widget. Append a number to 'stem' such that the result is a unique name.

(annot, stem)

Source from the content-addressed store, hash-verified

18559
18560
18561def JM_add_annot_id(annot, stem):
18562 '''
18563 Add a unique /NM key to an annotation or widget.
18564 Append a number to 'stem' such that the result is a unique name.
18565 '''
18566 assert isinstance(annot, mupdf.PdfAnnot)
18567 page = _pdf_annot_page(annot)
18568 annot_obj = mupdf.pdf_annot_obj( annot)
18569 names = JM_get_annot_id_list(page)
18570 i = 0
18571 while 1:
18572 stem_id = f'{JM_annot_id_stem}-{stem}{i}'
18573 if stem_id not in names:
18574 break
18575 i += 1
18576 response = JM_StrAsChar(stem_id)
18577 name = mupdf.pdf_new_string( response, len(response))
18578 mupdf.pdf_dict_puts(annot_obj, "NM", name)
18579 page.doc().m_internal.resynth_required = 0
18580
18581
18582def JM_add_oc_object(pdf, ref, xref):

Callers 12

_add_caret_annotMethod · 0.85
_add_file_annotMethod · 0.85
_add_freetext_annotMethod · 0.85
_add_ink_annotMethod · 0.85
_add_line_annotMethod · 0.85
_add_multilineMethod · 0.85
_add_redact_annotMethod · 0.85
_add_square_or_circleMethod · 0.85
_add_stamp_annotMethod · 0.85
_add_text_annotMethod · 0.85
_addWidgetMethod · 0.85
Page__add_text_markerFunction · 0.85

Calls 3

_pdf_annot_pageFunction · 0.85
JM_get_annot_id_listFunction · 0.85
JM_StrAsCharFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…