perform some cleaning if we have /EmbeddedFiles: (1) remove any /Limits if /Names exists (2) remove any empty /Collection (3) set /PageMode/UseAttachments
(pdf)
| 19251 | |
| 19252 | |
| 19253 | def 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 | |
| 19277 | def JM_EscapeStrFromBuffer(buff): |
no test coverage detected
searching dependent graphs…