The clean utility will produce a cleaned version of an input PDF. It can apply a range of different options, a full list of which can be obtained by running mutool clean with no options:
The arguments here are fairly self explanatory, and usage is best explained with a few examples.
Firstly, and most simply, clean can be used to try to repair broken files. Many PDF files found in the wild are broken - sometimes because of having been corrupted, either by transmission/archiving problems, but a disappointing amount by just having been created by bad PDF writing software. Running a clean pass will attempt to repair the files:
Individual pages (or page ranges) can be extracted from a PDF. For example:
That will extract the pages 1 to 10, and page 12 of in.pdf and output it into a new out.pdf. The -gggg options ensure that unused objects will be dropped from the PDF.
An 8 page PDF might be rearranged into booklet form using:
Finally, a more exotic, but very common example; if someone reports a problem seen on page 4 of a given PDF, the following command will extract that page, and expand the content streams, without decompressing the images or the fonts:
If this file still exhibits the same problem, it is generally far easier to debug through it than the original one was.