MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / clean

Function clean

src/__main__.py:220–264  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

218
219
220def clean(args):
221 doc = open_file(args.input, args.password, pdf=True)
222 encryption = args.encryption
223 encrypt = ("keep", "none", "rc4-40", "rc4-128", "aes-128", "aes-256").index(
224 encryption
225 )
226
227 if not args.pages: # simple cleaning
228 doc.save(
229 args.output,
230 garbage=args.garbage,
231 deflate=args.compress,
232 pretty=args.pretty,
233 clean=args.sanitize,
234 ascii=args.ascii,
235 linear=args.linear,
236 encryption=encrypt,
237 owner_pw=args.owner,
238 user_pw=args.user,
239 permissions=args.permission,
240 )
241 return
242
243 # create sub document from page numbers
244 pages = get_list(args.pages, doc.page_count + 1)
245 outdoc = pymupdf.open()
246 for pno in pages:
247 n = pno - 1
248 outdoc.insert_pdf(doc, from_page=n, to_page=n)
249 outdoc.save(
250 args.output,
251 garbage=args.garbage,
252 deflate=args.compress,
253 pretty=args.pretty,
254 clean=args.sanitize,
255 ascii=args.ascii,
256 linear=args.linear,
257 encryption=encrypt,
258 owner_pw=args.owner,
259 user_pw=args.user,
260 permissions=args.permission,
261 )
262 doc.close()
263 outdoc.close()
264 return
265
266
267def doc_join(args):

Callers

nothing calls this directly

Calls 5

insert_pdfMethod · 0.80
open_fileFunction · 0.70
get_listFunction · 0.70
saveMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…