mutool clean¶
The clean command pretty prints and rewrites the syntax of a PDF file. It can be used to repair broken files, expand compressed streams, filter out a range of pages, etc.
mutool clean [options] input.pdf [output.pdf] [pages]
[options]Options are as follows:
-ppasswordUse the specified password if the file is encrypted.
-gGarbage collect unused objects.
-ggIn addition to
-gcompact xref table.-gggIn addition to
-ggmerge duplicate objects.-ggggIn addition to
-gggcheck streams for duplication.-lLinearize PDF (no longer supported!).
-DSave file without encryption.
-EencryptionSave file with new encryption (
rc4-40,rc4-128,aes-128, oraes-256).-Oowner_passwordOwner password (only if encrypting).
-Uuser_passwordUser password (only if encrypting).
-PpermissionPermission flags (only if encrypting).
-aASCII hex encode binary streams.
-dDecompress streams.
-zDeflate uncompressed streams.
-fCompress font streams.
-iCompress image streams.
-cPretty-print graphics commands in content streams.
-sSanitize graphics commands in content streams.
-tCompact object syntax.
-ttUse indented object syntax to make PDF objects more readable.
-LPrint comments containing labels showing how each object can be reached from the Root.
-ACreate appearance streams for annotations that are missing appearance streams.
-AARecreate appearance streams for all annotations.
-mPreserve metadata.
-SSubset fonts if possible. (EXPERIMENTAL!)
-ZUse object streams cross reference streams for extra compression.
--(color|gray|bitonal)-(|lossy-|lossless-)image-subsample-method methodSet the subsampling method (
average, orbicubic) for the desired image types, for example color-lossy and bitonal-lossless.--(color|gray|bitonal)-(|lossy-|lossless-)image-subsample-dpi dpiSet the resolution at which to subsample.
--(color|gray|bitonal)-(|lossy-|lossless-)image-recompress-method qualitySet the recompression quality to either of
never,same,lossless,jpeg,j2k,fax, orjbig2.--structure=keep|dropKeep or drop the structure tree.
input.pdfInput file name. Must be a PDF file.
[output.pdf]The output file. Must be a PDF file.
If no output file is specified, it will write the cleaned PDF to “out.pdf” in the current directory.
[pages]Comma separated list of page numbers and ranges (for example: 1,5,10-15,20-N), where the character N denotes the last page. If no pages are specified, then all pages will be included.