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

Function JM_gather_forms

src/__init__.py:19499–19536  ·  view source on GitHub ↗

Store info of a /Form xobject in Python list

(doc, dict_: mupdf.PdfObj, imagelist, stream_xref: int)

Source from the content-addressed store, hash-verified

19497
19498
19499def JM_gather_forms(doc, dict_: mupdf.PdfObj, imagelist, stream_xref: int):
19500 '''
19501 Store info of a /Form xobject in Python list
19502 '''
19503 assert isinstance(doc, mupdf.PdfDocument)
19504 rc = 1
19505 n = mupdf.pdf_dict_len(dict_)
19506 for i in range(n):
19507 refname = mupdf.pdf_dict_get_key( dict_, i)
19508 imagedict = mupdf.pdf_dict_get_val(dict_, i)
19509 if not mupdf.pdf_is_dict(imagedict):
19510 mupdf.fz_warn( f"'{mupdf.pdf_to_name(refname)}' is no form dict ({mupdf.pdf_to_num(imagedict)} 0 R)")
19511 continue
19512
19513 type_ = mupdf.pdf_dict_get(imagedict, PDF_NAME('Subtype'))
19514 if not mupdf.pdf_name_eq(type_, PDF_NAME('Form')):
19515 continue
19516
19517 o = mupdf.pdf_dict_get(imagedict, PDF_NAME('BBox'))
19518 m = mupdf.pdf_dict_get(imagedict, PDF_NAME('Matrix'))
19519 if m.m_internal:
19520 mat = mupdf.pdf_to_matrix(m)
19521 else:
19522 mat = mupdf.FzMatrix()
19523 if o.m_internal:
19524 bbox = mupdf.fz_transform_rect( mupdf.pdf_to_rect(o), mat)
19525 else:
19526 bbox = mupdf.FzRect(mupdf.FzRect.Fixed_INFINITE)
19527 xref = mupdf.pdf_to_num(imagedict)
19528
19529 entry = (
19530 xref,
19531 mupdf.pdf_to_name( refname),
19532 stream_xref,
19533 JM_py_from_rect(bbox),
19534 )
19535 imagelist.append(entry)
19536 return rc
19537
19538
19539def JM_gather_images(doc: mupdf.PdfDocument, dict_: mupdf.PdfObj, imagelist, stream_xref: int):

Callers 1

JM_scan_resourcesFunction · 0.85

Calls 3

PDF_NAMEFunction · 0.85
JM_py_from_rectFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…