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
Input file name. The input can be any of the document formats supported by MuPDF: PDF, XPS, CBZ, unprotected EPUB, FB2, etc.
[pages]
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.
-X
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=N
Rotate rendered pages N degrees counter-clockwise.
resolution=N
Set both X and Y resolution in pixels per inch.
x-resolution=N
Set X resolution in pixels per inch.
y-resolution=N
Set Y resolution in pixels per inch.
width=N
Render pages to fit N pixels wide (ignore resolution options).
height=N
Render pages to fit N pixels tall (ignore resolution options).
colorspace=gray/rgb/cmyk
Render using specified colorspace (if output format supports it).
alpha
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
Decompress all streams (except compress-fonts/images).
compress
Compress all streams.
compress-fonts
Compress embedded fonts.
compress-images
Compress images.
ascii
ASCII hex encode binary streams.
pretty
Pretty-print objects with indentation.
linearize
Optimize for web browsers.
sanitize
Clean up graphics commands in content streams.
garbage
Garbage collect unused objects.
garbage=compact
... and compact cross reference table.
garbage=deduplicate
... 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:

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