FreeBSD Manual Pages
MUTOOL(1) General Commands Manual MUTOOL(1) NAME mutool - all purpose tool for dealing with PDF files SYNOPSIS mutool <sub-command> [options] VERSION mutool -v Shows the MuPDF version used to build mutool. DESCRIPTION mutool is a tool based on MuPDF for dealing with document files in various manners. There are several sub commands available, as described below. DRAW mutool draw [options] file [pages] The draw command will render a document to image files, convert to another vector format, or extract the text content. The supported input document formats are: pdf, xps, cbz, and epub. The supported output image formats are: pbm, pgm, ppm, pam, png, pwg, pcl and ps. The supported output vector formats are: svg, pdf, and debug trace (as xml). The supported output text formats are: plain text, html, and structured text (as xml). -p password Use the specified password if the file is encrypted. -o output The output format is inferred from the output filename. Embed %d in the name to indicate the page number (for example: "page%d.png"). Printf modifiers are supported, for example "%03d". If no output is specified, the output will go to stdout. -F format Enforce a specific output format. Only necessary when outputting to stdout since normally the output filename is used to infer the output format. -q Be quiet, do not print progress messages. -R angle Rotate clockwise by given number of degrees. -r resolution Render the page at the specified resolution. The default resolution is 72 dpi. -w width Render the page at the specified width (or, if the -r flag is used, render with a maximum width). -h height Render the page at the specified height (or, if the -r flag is used, render with a maximum height). -f Fit exactly; ignore the aspect ratio when matching specified width/heights. -b box Use name page box (`MediaBox`, `CropBox`, `BleedBox`, `TrimBox`, or `ArtBox`), see :ref:`defined boxes<mutool_trim_defined_boxes>`. -B bandheight Render in banded mode with each band no taller than the given height. This uses less memory during rendering. Only compatible with pam, pgm, ppm, pnm and png output formats. Banded rendering and md5 checksumming may not be used at the same time. -T threads Number of threads to use for rendering (banded mode only). -W width Page width in points for EPUB layout. -H height Page height in points for EPUB layout. -S size Font size in points for EPUB layout. -U filename User CSS stylesheet for EPUB layout. -X Disable document styles for EPUB layout. -a Disable usage of accelerator file. -c colorspace Render in the specified colorspace. Supported colorspaces are: mono, gray, grayalpha, rgb, rgbalpha, cmyk, cmykalpha. Some abbreviations are allowed: m, g, ga, rgba, cmyka. The default is chosen based on the output format. -e filename Proof ICC profile filename to use for rendering. -G gamma Apply gamma correction. Some typical values are 0.7 or 1.4 to thin or darken text rendering. -I Invert colors. -s [mft5] Show various bits of information: m for glyph cache and total memory usage, f for page features such as whether the page is grayscale or color, t for per page rendering times as well statistics, and 5 for md5 checksums of rendered images that can be used to check if rendering has changed. -A bits Specify how many bits of anti-aliasing to use. The default is 8. -A bits/bits Specify how many bits of anti-aliasing to use. The default is 8. Bits for graphics is before the slash, bits for text after the slash. -l width Minimum stroked line width (in pixels). -K Do not draw text. -KK Only draw text. -D Disable use of display lists. May cause slowdowns, but should reduce the amount of memory used. -i Ignore errors. -m limit Limit memory usage in bytes. -L Low memory mode (avoid caching objects by clearing cache after each page). -P Run interpretation and rendering at the same time. -N Disable ICC workflow. -O overprint Control spot/overprint rendering: 0 for no spot rendering, 1 for Overprint simulation (default), or 2ffor full spot rendering. -t language Specify language/script for OCR (default: eng) -d ocr-file-path Specify path for OCR files (default: rely on TESSDATA_PREFIX environment variable. -k correction Set the skew correction, either one of auto, 0 for increase size, 1 for maintain size, or 2 for decrease size. -k correction,angle Set the skew correction as well as the angle. -y l Print the layer configs to stderr. -y layer-number Select layer config (by number from -y l). -y layer-number,item1,item2,... Select layer config (by number from -y l) and toggle the listed items. -Y Print the individual layers to stderr. -z layer-number Hide individual layer. -Z layer-number Show individual layer. 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 rendered. CLEAN mutool clean [options] input.pdf [output.pdf] [pages] 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. If no output file is specified, it will write the cleaned PDF to "out.pdf" in the current directory. -p password Use the specified password if the file is encrypted. -g Garbage collect objects that have no references from other objects. Give the option twice to also renumber all objects and compact the cross reference table. Give it three times to also merge and reuse duplicate objects. Give it four times to also merge and reuse duplicate streams. -s Rewrite content streams. -l Linearize output. No longer supported! Used to ccreate a "Web Optimized" output file. -D Save file without encryption. -E method Save file with desired encryption method, one of: rc4-40 rc4-128 aes-128, or aes-256. -O password Owner password used when encrypting output file. This is required to edit the output file. -U password User password used when encrypting output file. This is required to view the output file. -P permissions Permissions used when encrypting output file. These are the permissions that apply when the output file is viewed. -a ASCII Hex encode binary streams. Use in conjunction with -d and -i or -f to ensure that although the images and/or fonts are compressed, the resulting file can still be viewed and edited with a text editor. -d Decompress streams. This will make the output file larger, but provides easy access for reading and editing the contents with a text editor. -z Deflate uncompressed streams. If combined with -d, any decompressed streams will be recompressed. If combined with -a, the streams will also be hex encoded after compression. -e effort Configure how much effort is spent compressing the output file. 0 is default amount, otherwise a percentage of the maximum effort, 1 for minimum and 100 for maximum effort. -f Toggle decompression of font streams. Use in conjunction with -d to leave fonts compressed. -i Toggle decompression of image streams. Use in conjunction with -d to leave images compressed. -c Pretty-print graphics commands in content streams. -s Sanitize graphics commands in content streams, this means, for example, removing invalid or redundant commands. -t Use compact PDF object syntax. This saves space. -tt Use indented PDF object syntax. This is more human-readable. -L Print comments containing labels showing how each object can be reached from the Root. -A Create appearance streams for annotations that are missing appearance streams. -AA Recreate appearance streams for all annotations. -m Preserve metadata. -S Subset fonts if possible. (EXPERIMENTAL!) -Z Use object streams cross reference streams for extra compressoin. --(color,gray,bitonal)-(,lossy-,lossless-)image-subsample-method method Set the subsampling method (average, or bicubic) for the desired image types, for example color-lossy and bitonal-loessless. --(color,gray,bitonal)-(,lossy-,lossless-)image-subsample-dpi dpi Set the resolution at which to subsample. --(color,gray,bitonal)-(,lossy-,lossless-)image-recompress-method quality Set the recompression quality to either of never, same, lossless, jpeg, j2k, fax, or jbig2. --structure=(keep|drop) Keep or drop the structure tree. 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. EXTRACT mutool extract [options] file.pdf [object numbers] The extract command can be used to extract images and font files from a PDF. If no object numbers are given on the command line, all images and fonts will be extracted. -p password Use the specified password if the file is encrypted. -r Convert images to RGB when extracting them. -a Embed SMasks as alpha channel.. -N Do not use ICC color conversions. INFO mutool info [options] file.pdf [pages] The info command lists the resources used on each page in a PDF file. The default is to list all resource types, but if one or more flags are given, only the flagged types will be shown. -p password Use the specified password if the file is encrypted. -F List fonts. -I List images. -M List page dimensions. -S List shadings. -P List patterns. -X List form and postscript XObjects. -Z List ZUGFeRD info. 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. CREATE mutool create [-o output.pdf] [options] page1.txt [page2.txt ...] The create command creates a new PDF file with the contents created from one or more input files containing graphics commands. -o output If no output file is specified, it will write the created PDF to "out.pdf" in the current directory. page.txt A page is created for each input file, with the contents of the file copied into the content stream. Special comments in the input files are parsed to define the page dimensions and font and image resources: %%MediaBox 0 0 500 800 %%Rotate 90 %%Font Tm Times-Roman %%Font Fn0 path/to/font/file.ttf %%Image Im0 path/to/image.png -O options Comma separated list of format specific output options, see OUTPUT OPTIONS below. PAGES mutool pages [options] input.pdf [pages ...] The pages command dumps information about the size and orientation of pages within the document. -p password Use the specified password if the file is encrypted. 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. POSTER mutool poster [options] input.pdf [output.pdf] The poster command splits each page into tiles, and puts each tile on a page of its own. It's useful for printing a large page onto smaller pieces of paper that can then be glued together to create a large poster. -p password Use the specified password if the file is encrypted. -m margin Margin (overlap) between pages in points or percent. -x factor Split the page into this many horizontal pieces. -y factor Split the page into this many vertical pieces. -r Splits hoirzontally from right to left (default splits from left to right). The output will have x times y number of pages for each input page. SHOW mutool show [options] file.pdf [object numbers ...] The show command will print the specified objects and streams to stdout. Streams are decoded and non-printable characters are represented with a period by default. -p password Use the specified password if the file is encrypted. -o file Write output to file instead of stdout. -b Print streams as binary data and omit the object header. -e Print streams in their original encoded (or compressed) form. -g Print each object on a single line, suitable for grep. -r Force repair before showing any objects. Specify objects by number, or use one of the following special names: 'xref' Print the cross reference table. 'trailer' Print the trailer dictionary. 'encrypt' Print the encryption dictionary. 'pagetree' List the object numbers for every page. 'grep' Print all the objects in the file in a compact one-line format suitable for piping to grep. 'outline' Print the outline (table of contents). RUN mutool run script.js [arguments] Executes a Javascript program which has access to most of the features of the MuPDF library. The command supports ECMAScript 5 syntax in strict mode. All of the MuPDF constructors and function live in the global object, and the command line arguments are accessible from the global argv object. If invoke without any arguments, it will drop you into an interactive REPL (read-eval-print-loop). On the interactive prompt, if you prefix a line with an equal character it will automatically print the results of the line. See the MuPDF documentation for details about the Javascript interfaces. CONVERT mutool convert [options] file [pages] The convert command is used to convert a file from one format to another. -p password Use the specified password if the file is encrypted. -b box Use name page box (`MediaBox`, `CropBox`, `BleedBox`, `TrimBox`, or `ArtBox`), see :ref:`defined boxes<mutool_trim_defined_boxes>`. -A bits Specify how many bits of anti-aliasing to use. The default is 8. -W width Page width in points for EPUB layout. -H height Page height in points for EPUB layout. -S size Font size in points for EPUB layout. -U filename User CSS stylesheet for EPUB layout. -o output The output format is inferred from the output filename. Embed %d in the name to indicate the page number (for example: "page%d.png"). Printf modifiers are supported, for example "%03d". If no output is specified, the output will go to stdout. -F format Enforce a specific output format. Only necessary when outputting to stdout since normally the output filename is used to infer the output format. -O options Comma separated list of format specific output options, see OUTPUT OPTIONS below. MERGE mutool merge [options] file1 [pages] file2 [pages] ... The merge command is used to pick out pages from two or more files and merge them in order into a new PDF output file. -o output The output filename. -O options Comma separated list of format specific output options, see OUTPUT OPTIONS below. BAKE mutool bake [options] input.pdf [output.pdf] Normally annotations and form field widgets are separate content streams that get drawn on top of the page contents. This command bakes annotations and/or widgets into the page contents, making them inseparable. After baking in annotations and widgets they are just visual representaitons of what the original annotation/widget looked like, their properties can no longer be edited since they no longer exist as proper annotation/widgets. -A Do not bake in annotations. -F Do not bake in form field widgets. -O options A comma separated list of PDF options. See OUTPUT OPTIONS below. RECOLOR mutool recolor [options] input.pdf Change the color space used in a PDF to a desired one. This command can, for example, change a color PDF to be grayscale. -c colorspace Desired output colorspace, choose one of gray (default), rgb, or cmyk. -r Remove any output intents. -o filename The output filename. TRACE mutool trace [options] file1 [pages] file2 [pages] ... Prints a trace of device calls needed to render the desired pages from the given document. -p password Use the specified password if the file is encrypted. -W width Page width in points for EPUB layout. -H height Page height in points for EPUB layout. -S size Font size in points for EPUB layout. -U filename User CSS stylesheet for EPUB layout. -X Disable document styles for EPUB layout. -d Enable use of display lists. 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 rendered. TRIM mutool trim [options] input.pdf Makes a modified version of a PDF with content that falls inside (or outside) of the given box removed. -b box Which box to trim to, either one of: MediaBox (default) CropBox BleedBox TrimBox, or ArtBox. -f Fallback to mediabox if specified box not available. -m all Add same margins to all sides of the box, where all is positive for inwards, negative for outwards. -m vertical,horizontal Add specific margins for vertical and horizontal sides of the box, where vertical and horizonal are positive for inwards, negative for outwards. -m top,right,bottom,left Add specific margins for top, right, bottom and left sides of the box, where top, right, bottom, and left each are positive for inwards, negative for outwards. -e Exclude contents of box rather than include them. -o filename The output filename. SIGN mutool sign [options] input.pdf [signature object number] Reads a PDF file and prints infromation about each signature field object. With suitable options all or specified signatures can be verified, cleared or signed. -p password Use the specified password if the file is encrypted. -v Verify all signatures, or only the specified signature. -c Clear all signatures, or only the specified signature. -s certificate-filename Read a certificate from the given filename and use it to sign all, or just the specified signature. -P certificate-password Use the specified password when opening the certificate. -o filename The output filename. signature object numbers A list of PDF object number for signatures to verify/clear/sign. If no such object numbers are given, all signatures will be processed. AUDIT mutool audit [options] file1.pdf file2.pdf ... Outputs a report of operator and space usage for each given PDF file. -o filename The output filename for the report. OUTPUT OPTIONS Configuring output is done by a comma separated list of output options. Raster format options These apply to output formats: cbz, png, pnm, pgm, ppm, pam, pbm, pkm. rotate=N Rotate rendered pagess N degrees counterclockwise. resoution=N Set both X and Y resolution in pixels per inch. x-resolution=N Set X resolution of rendred pages in pixels per inch. y-resolution=N Set Y resolution of rendred pages in pixels per inch. width=N Render pages to fit N pixels wide (ignore resolution option). height=N Render pages to fit N pixels tall (ignore resolution option). colorspace=(gray|rgb|cmyk) Render pages using the specified colorspace. alpha Render pages with alpha channel and transparent background. graphics=(aaN|cop|app) text=(aaN|cop|app) Set the rasterizer to use for graphics or text respectively: aaN Antialias with N bits (0 to 8). cop Center of pixel. app Any part of pixel. PDF options decompress Decompress all streams (except compress-fonts/images). compress=(yes|flate|brotli) Compress all streams, if no value is given, or the value is yesfthe default is to use flate. compress-fonts Compress object stream for embedded fonts. compress-images Compress object streams for images. compress-effort=(0|PERCENTAGE) Effort spent compressing, 0 is default, otherwise percentage of max effort. ascii Encode object streams using ASCII hex encoding. pretty Pretty-print objects with indentation. labels Print object labels. linearize Optimize document for progressive loading in viewers ( no longer supported!). clean Pretty-print graphics commands in content streams. sanitize Clean up graphics command in content streams. garbage Garbage collect unused objects. garbage=compact Garbage collect unused object, and compact cross reference table. garbage=deduplicate Garbage collect unused objects, compact cross reference table, and recombine duplicate objects. incremental Write changes as incremental update. objstms Use object streams and cross reference streams. appearance=(yes|all) Synthesize just missing, or all, annotation/widget apperance streams. continue-on-error Continue saving the document even if there is an error. decrypt Write unencrypted document. encrypt=(none|keep|rc4-40|rc4-128|aes-128|aes-256) Write encrypted document using specified encryption method. permissions=NUMBER Document permissions to grant when encrypting. user-password=PASSWORD Password required to read document. owner-password=PASSWORD Password required to edit document. regenerate-id=no Regenerate document id (default yes). Text format options These apply to formats: html, xhtml, text stext. preserve-images Keep imagess in output. preserve-ligatures Do not expand ligature into constituent characters. preserve-spans Do not merge spans on the same line. preserve-whitespace Do not convert all whitespace into space characters. inhibit-spaces Do not add spaces between gaps in the text. paragraph-break Break blocks at paragraph boundaries. dehyphenate Attempts to join up hyphenated words. ignore-actualtext Do not apply ActualText replacements. use-cid-for-unknown-unicode Use character code if unicode mapping fails. use-gid-for-unknown-unicode Use glyph index if unicode mapping fails. accurate-bboxes Calculate bboxes from the outlines. accurate-ascenders Calculate ascender/descender from font glyphs. accurate-side-bearings Expand character bboxes to completely include width of glyphs. collect-styles Attempt to detect text features (fake bold, strikeout, underlined, etc.) clip Do not include text that is completely clipped. clip-rect=x0:y0:x1:y1 Specify clipping rectangle within which to collect content. structured Collect structure markup. vectors Include vector bboxes in output. segment Attempt to segment the page. table-hunt Hunt for tables within a (segmented) page. PCL options colorspace=(mono|rgb) Render 1-bit black and white or a full color page. preset=(generic|ljet4|dj500|fs600|lj|lj2|lj3|lj4|lj4pl|lj4d|lp2563b|oce9050) Render 1-bit black and white or a full color page. spacing=(0|1|2|3) Set vertical spacing to none, PCL 3 (<ESC>*p+<n>Y), PCL 5 (<ESC>*b<n>Y), or PCL 6 (<ESC>*b<n>Y and clear seed row). mode2 Enable mode 2 graphics compression. mode3 Enable mode 3 graphics compression. eog_reset End of graphics (<ESC>+rB) resets all parameters. has_duplex Duplex supported (<ESC>&l<duplex>S). has_papersize Papersize setting supported (<ESC>&l<sizecode>A). has_copies Number of copies supported (<ESC>&l<copies>X). is_ljet4pjl Disable/enable HP 4PJL model-specific output. is_oce9050 Disable/enable Oce 9050 models-specific output. PCLm options compression=(none|flate) No compression (default), or enable flate compression. strip-height=N Strip height (default 16). PWG options media_class=<string> Set the media_class field. media_color=<string> Set the media_color field. media_type=<string> Set the media_type field. output_type=<string> Set the output_type field. rendering_intent=<string> Set the rendering_intent field. page_size_name=<string> Set the page_size_name field. advance_distance=<int> Set the advance_distance field. advance_media=<int> Set the advance_media field. collate=<int> Set the collate field. cut_media=<int> Set the cut_media field. duplex=<int> Set the duplex field. insert_sheet=<int> Set the insert_sheet field. jog=<int> Set the jog field. leading_edge=<int> Set the leading_edge field. manual_feed=<int> Set the manual_feed field. media_position=<int> Set the media_position field. media_weight=<int> Set the media_weight field. mirror_print=<int> Set the mirror_print field. negative_print=<int> Set the negative_print field. num_copies=<int> Set the num_copies field. orientation=<int> Set the orientation field. output_face_up=<int> Set the output_face_up field. page_size_x=<int> Set the page_size_x field. page_size_y=<int> Set the page_size_y field. separations=<int> Set the separations field. tray_switch=<int> Set the tray_switch field. tumble=<int> Set the tumble field. media_type_num=<int> Set the media_type_num field. compression=<int> Set the compression field. row_count=<int> Set the row_count field. row_feed=<int> Set the row_feed field. row_step=<int> Set the row_step field. SVG options text=text Emit text as <text> elements (inaccurate fonts). text=path Emit text as <path> elements (accurate fonts). no-reuse-images Do not reuse image using <symbol> definitions. EXIT STATUS The exit status is 0 upon successful execution and non-zero upon error. SEE ALSO mupdf(1), AUTHOR MuPDF is Copyright 2004-2025 Artifex Software, Inc. April 14, 2025 MUTOOL(1)
NAME | SYNOPSIS | VERSION | DESCRIPTION | DRAW | CLEAN | EXTRACT | INFO | CREATE | PAGES | POSTER | SHOW | RUN | CONVERT | MERGE | BAKE | RECOLOR | TRACE | TRIM | SIGN | AUDIT | OUTPUT OPTIONS | EXIT STATUS | SEE ALSO | AUTHOR
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=mutool&sektion=1&manpath=FreeBSD+Ports+15.0>
