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

Method _add_ink_annot

src/__init__.py:9647–9677  ·  view source on GitHub ↗
(self, list)

Source from the content-addressed store, hash-verified

9645 return val
9646
9647 def _add_ink_annot(self, list):
9648 page = _as_pdf_page(self.this)
9649 if not PySequence_Check(list):
9650 raise ValueError( MSG_BAD_ARG_INK_ANNOT)
9651 ctm = mupdf.FzMatrix()
9652 mupdf.pdf_page_transform(page, mupdf.FzRect(0), ctm)
9653 inv_ctm = mupdf.fz_invert_matrix(ctm)
9654 annot = mupdf.pdf_create_annot(page, mupdf.PDF_ANNOT_INK)
9655 annot_obj = mupdf.pdf_annot_obj(annot)
9656 n0 = len(list)
9657 inklist = mupdf.pdf_new_array(page.doc(), n0)
9658
9659 for j in range(n0):
9660 sublist = list[j]
9661 n1 = len(sublist)
9662 stroke = mupdf.pdf_new_array(page.doc(), 2 * n1)
9663
9664 for i in range(n1):
9665 p = sublist[i]
9666 if not PySequence_Check(p) or PySequence_Size(p) != 2:
9667 raise ValueError( MSG_BAD_ARG_INK_ANNOT)
9668 point = mupdf.fz_transform_point(JM_point_from_py(p), inv_ctm)
9669 mupdf.pdf_array_push_real(stroke, point.x)
9670 mupdf.pdf_array_push_real(stroke, point.y)
9671
9672 mupdf.pdf_array_push(inklist, stroke)
9673
9674 mupdf.pdf_dict_put(annot_obj, PDF_NAME('InkList'), inklist)
9675 mupdf.pdf_update_annot(annot)
9676 JM_add_annot_id(annot, "A")
9677 return Annot(annot)
9678
9679 def _add_line_annot(self, p1, p2):
9680 page = self._pdf_page()

Callers 1

add_ink_annotMethod · 0.95

Calls 7

_as_pdf_pageFunction · 0.85
PySequence_CheckFunction · 0.85
PySequence_SizeFunction · 0.85
JM_point_from_pyFunction · 0.85
PDF_NAMEFunction · 0.85
JM_add_annot_idFunction · 0.85
AnnotClass · 0.85

Tested by

no test coverage detected