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

Method _addFormFont

src/__init__.py:3059–3077  ·  view source on GitHub ↗

Add new form font.

(self, name, font)

Source from the content-addressed store, hash-verified

3057 return f"{is_closed}Document('{self.name}', <memory, doc# {self._graft_id:d}>)"
3058
3059 def _addFormFont(self, name, font):
3060 """Add new form font."""
3061 if self.is_closed or self.is_encrypted:
3062 raise ValueError("document closed or encrypted")
3063 pdf = _as_pdf_document(self, required=0)
3064 if not pdf.m_internal:
3065 return
3066 fonts = mupdf.pdf_dict_getl(
3067 mupdf.pdf_trailer( pdf),
3068 PDF_NAME('Root'),
3069 PDF_NAME('AcroForm'),
3070 PDF_NAME('DR'),
3071 PDF_NAME('Font'),
3072 )
3073 if not fonts.m_internal or not mupdf.pdf_is_dict( fonts):
3074 raise RuntimeError( "PDF has no form fonts yet")
3075 k = mupdf.pdf_new_name( name)
3076 v = JM_pdf_obj_from_str( pdf, font)
3077 mupdf.pdf_dict_put( fonts, k, v)
3078
3079 def del_toc_item(
3080 self,

Callers

nothing calls this directly

Calls 4

_as_pdf_documentFunction · 0.85
PDF_NAMEFunction · 0.85
JM_pdf_obj_from_strFunction · 0.85
pdf_trailerMethod · 0.80

Tested by

no test coverage detected