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

Function JM_embedded_clean

src/__init__.py:19253–19274  ·  view source on GitHub ↗

perform some cleaning if we have /EmbeddedFiles: (1) remove any /Limits if /Names exists (2) remove any empty /Collection (3) set /PageMode/UseAttachments

(pdf)

Source from the content-addressed store, hash-verified

19251
19252
19253def JM_embedded_clean(pdf):
19254 '''
19255 perform some cleaning if we have /EmbeddedFiles:
19256 (1) remove any /Limits if /Names exists
19257 (2) remove any empty /Collection
19258 (3) set /PageMode/UseAttachments
19259 '''
19260 root = mupdf.pdf_dict_get( mupdf.pdf_trailer( pdf), PDF_NAME('Root'))
19261
19262 # remove any empty /Collection entry
19263 coll = mupdf.pdf_dict_get(root, PDF_NAME('Collection'))
19264 if coll.m_internal and mupdf.pdf_dict_len(coll) == 0:
19265 mupdf.pdf_dict_del(root, PDF_NAME('Collection'))
19266
19267 efiles = mupdf.pdf_dict_getl(
19268 root,
19269 PDF_NAME('Names'),
19270 PDF_NAME('EmbeddedFiles'),
19271 PDF_NAME('Names'),
19272 )
19273 if efiles.m_internal:
19274 mupdf.pdf_dict_put_name(root, PDF_NAME('PageMode'), "UseAttachments")
19275
19276
19277def JM_EscapeStrFromBuffer(buff):

Callers 1

saveMethod · 0.85

Calls 2

PDF_NAMEFunction · 0.85
pdf_trailerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…