mutool convert

The 'mutool convert' command converts an input file into another format.

mutool convert [options] -o output input [pages]

The command line options are:

Input file name. The input can be any of the document formats supported by MuPDF: PDF, XPS, CBZ, unprotected EPUB, FB2, etc.
Comma separated list of page ranges. The first page is "1", and the last page is "N". The default is "1-N".
-p password
Password to use for password protected PDF documents.
-o filename
The output file name. The output file name may have a "%d" in the path, which will be replaced with the page number. If there is no %d, the page number will be appended at the end of the file name for single page formats.
-F format
The output format. If missing, it is inferred from the output file name extension. See below for which formats are supported.
-O options
Comma separated list of output options. The set of available options varies depending on the output format. See below for details.
-A bits
Number of bits of anti-aliasing to use (0 to 8) when rendering to image based formats. The default is 8.
-W width
Page width in points for EPUB layout.
-H height
Page height in points for EPUB layout.
-S font-size
Font size in points for EPUB layout.
-U stylesheet.css
File name of user style sheet for EPUB layout.
Disable document styles for EPUB layout.

Image output

CBZ (comic book zip) is a multi-page image format.

The following single page image formats are also supported: PNG, PNM, PAM, TGA, PBM, PKM. Each page is written to a separate file.

The output options (-O flag) for image formats are:

Rotate rendered pages N degrees counter-clockwise.
Set both X and Y resolution in pixels per inch.
Set X resolution in pixels per inch.
Set Y resolution in pixels per inch.
Render pages to fit N pixels wide (ignore resolution options).
Render pages to fit N pixels tall (ignore resolution options).
Render using specified colorspace (if output format supports it).
Render pages with an alpha channel and transparent background (if output format supports it).

PDF output

With PDF output, we will create a new PDF file that matches the visual appearance. The PDF output is still a work in progress, so some features may not work.

If the input is PDF, the output will have nothing in common except the visual appearance. All bookmarks, annotations, forms, etc, will be thrown away. If you want to do a PDF to PDF conversion, 'mutool clean' is a better tool to use.

The PDF output options are:

Decompress all streams (except compress-fonts/images).
Compress all streams.
Compress embedded fonts.
Compress images.
ASCII hex encode binary streams.
Pretty-print objects with indentation.
Optimize for web browsers.
Clean up graphics commands in content streams.
Garbage collect unused objects.
... and compact cross reference table.
... and remove duplicate objects.

SVG output

SVG output is a single page format, so we will write one SVG file for each input page.

The SVG output options are:

Emit text as elements (inaccurate fonts).
Emit text as elements (accurate fonts).
Do not reuse images using <symbol> definitions.