A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-bash: mutool command not found #Debian apt-get install mupdf-tools #Ubuntu apt-get install mupdf-tools #Alpine apk add mupdf-tools #Arch Linux pacman -S mupdf-tools #Kali Linux apt-get install mupdf-tools #Fedora dnf install mupdf #OS X brew install mupdf-tools #Raspbian apt-get install mupdf-tools #Docker docker run cmd.cat/mutool mutool
MuPDF 是一个开放源代码软件框架,用于查看和转换 PDF、XPS 和电子书文档。有用于各种平台的查看器,几种命令行工具以及用于构建工具和应用程序的软件库。
MuPDF 的命令行工具,全部收集到一个“伞”命令中:mutool。用于呈现和转换文档的三个命令可用:
还有一些专门用于处理 PDF 文件的工具:
最后,有一个工具可以做您可以想象的任何事情 mutool run:
mutool <sub-command> [options]
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, tga, 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.
-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 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.
-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.
-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.
-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.
-D Disable use of display lists. May cause slowdowns, but should reduce the amount of
memory used.
-i Ignore errors.
-L Low memory mode (avoid caching objects by clearing cache after each page).
-P Run interpretation and rendering at the same time.
pages Comma separated list of page numbers and ranges (for example: 1,5,10-15). 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 renumber all objects and compact the cross reference table. Give
it three times to merge and reuse duplicate objects.
-s Rewrite content streams.
-d Decompress streams. This will make the output file larger, but provides easy access
for reading and editing the contents with a text editor.
-l Linearize output. Create a "Web Optimized" output file.
-i Toggle decompression of image streams. Use in conjunction with -d to leave images
compressed.
-f Toggle decompression of font streams. Use in conjunction with -d to leave fonts
compressed.
-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.
-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.
pages Comma separated list of page numbers and ranges to include.
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.
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.
pages Comma separated list of page numbers and ranges to include.
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 Comma separated list of format specific output options:
decompress
Decompress all object streams.
compress
Compress all object streams.
compress-fonts
Compress object streams for embedded fonts.
compress-images
Compress object streams for images.
ascii
Encode object streams using ASCII hex encoding.
pretty
Pretty-print objects with indentation.
linearize
Optimize document for progressive loading in viewers.
sanitize
Clean up graphics command in content streams.
garbage[=compact|deduplicate]
Garbage collect unused objects. With compact the cross-reference table will also be
compacted. With deduplicate duplicate objects will also be recombined.
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 to include.
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.
-x factor
Split the page into this many horizontal pieces.
-y factor
Split the page into this many vertical pieces.
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.
Specify objects by number, or use one of the following special names:
'xref' or 'x'
Print the cross reference table.
'trailer' or 't'
Print the trailer dictionary.
'encrypt' or 'e'
Print the encryption dictionary.
'pagetree' or 'p'
List the object numbers for every page.
'grep' or 'g'
Print all the objects in the file in a compact one-line format suitable for piping
to grep.
'outline' or 'o'
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.
-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 Comma separated list of format specific output options:
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 output file.
-o output
The output filename.
-O See mutool create for details on this option.
需要操作的目标 PDF 文件
mutool convert 将第 1-10 页转换为 10 个 PNG 图像:
mutool convert -o image%d.png file.pdf 1-10
mutool draw 将 PDF 的第 2、3 和 5 页转换为标准输出中的文本:
mutool draw -F txt file.pdf 2,3,5
mutool merge 连接两个 PDF:
mutool merge -o output.pdf input1.pdf input2.pdf
mutool info 查询有关 PDF 中嵌入的所有内容的信息:
mutool info input.pdf
mutool extract 将嵌入 PDF 的所有图像,字体和资源提取到当前目录中:
mutool extract input.pdf