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

Method _setAP

src/__init__.py:659–677  ·  view source on GitHub ↗
(self, buffer_, rect=0)

Source from the content-addressed store, hash-verified

657 return r
658
659 def _setAP(self, buffer_, rect=0):
660 try:
661 annot = self.this
662 annot_obj = mupdf.pdf_annot_obj( annot)
663 page = _pdf_annot_page(annot)
664 apobj = mupdf.pdf_dict_getl( annot_obj, PDF_NAME('AP'), PDF_NAME('N'))
665 if not apobj.m_internal:
666 raise RuntimeError( MSG_BAD_APN)
667 if not mupdf.pdf_is_stream( apobj):
668 raise RuntimeError( MSG_BAD_APN)
669 res = JM_BufferFromBytes( buffer_)
670 if not res.m_internal:
671 raise ValueError( MSG_BAD_BUFFER)
672 JM_update_stream( page.doc(), apobj, res, 1)
673 if rect:
674 bbox = mupdf.pdf_dict_get_rect( annot_obj, PDF_NAME('Rect'))
675 mupdf.pdf_dict_put_rect( apobj, PDF_NAME('BBox'), bbox)
676 except Exception:
677 if g_exceptions_verbose: exception_info()
678
679 def _update_appearance(self, opacity=-1, blend_mode=None, fill_color=None, rotate=-1):
680 annot = self.this

Callers 2

updateMethod · 0.95
add_redact_annotMethod · 0.80

Calls 5

_pdf_annot_pageFunction · 0.85
PDF_NAMEFunction · 0.85
JM_BufferFromBytesFunction · 0.85
JM_update_streamFunction · 0.85
exception_infoFunction · 0.85

Tested by

no test coverage detected