MuPDF is an open-source software library for working with a wide range of document formats. Typical tasks include: rendering, converting to other formats, extracting resources, extracting plain text, filling out forms, adding annotations, redacting sensitive information, reordering and removing pages, and much more.
As you can tell by the name, we support reading PDF files. But that’s not all! We also handle XPS and various E-book formats. There is also limited support for reading Office format documents.
The command line tools are all gathered into one umbrella command: mutool. This swiss army
knife has a lot of sub-commands for performing different tasks on PDF
documents.
MuPDF can be used to render pages to images; or to convert a document into a multitude of other formats. This is an entirely visual conversion; metadata and other non-visible content will NOT be preserved.
These two tools provide this functionality. They both use the same conversion under the hood, but provide separate sets of command line options to fit different use cases.
mutool drawmutool convertSee document writer options and PDF write options to learn how to control the conversion behavior.
mutool draw can
also be used to extract detailed textual information in XML or JSON
format:
mutool draw [-O stext-options] -o output.stext input.pdf
mutool draw [-O stext-options] -o output.stext.json input.pdf
See stext-options for a description of the available structured text extraction options.
PDF files often have images, fonts, and other embedded files. These
can be extracted with mutool extract.
MuPDF has a large toolset for manipulating PDF files on the command line.
mutool showmutool cleanmutool createmutool mergemutool postermutool runmutool run. See the
library section below for ways to use MuPDF from other programming
languages.
For Linux, Windows and MacOS there are two viewer applications. The
main viewer mupdf-gl
has many features such as a table of contents sidebar, full unicode
search, annotation editing, and redaction. On systems where this viewer
cannot be built, the older legacy viewers (mupdf-x11, mupdf-win32) are
still supported.
Android currently has two different viewers with varying degrees of complexity:
MuPDF viewer A high performance PDF viewer with a smooth and polished interface.
MuPDF mini An example of how to create a PDF viewer with the least amount of code.
There’s also a commercial license (trial available) only MuPDF WebViewer product. Here is a demo of it.
A non-exhaustive list of other non-affiliated open source projects that use MuPDF for viewing:
The MuPDF library exposes all the functionality we support, so that applications built on top of the MuPDF library can do everything the tools described above can.
The MuPDF library is written in portable C. To learn more about the C interface, read the MuPDF Explored book.
Write Node or browser applications with the mupdf.js Javascript bindings.
There is a library available to use MuPDF from Javascript and Typescript, powered by WebAssembly. You can use this library to build applications that run in a web browser, or that run server side using Node. The Javascript library is available as a module on NPM.
The MuPDF.js library provides the same interface as the
mutool run scripting tool.
Use the MuPDF Java library to write applications in Java or to build an Android application.
The Java classes provide an interface very similar to the Javascript library.
If you want to build an application for Android, you can either base it off one of the existing viewers or build a new app from scratch using the MuPDF library directly.
The popular PyMuPDF library makes it trivial to use MuPDF from Python for extraction, conversion, and rendering alike.