PyMuPDF is a Python binding for the PDF rendering library MuPDF V 1.9a
Release date: August, 2016
This is version 1.9.2 of PyMuPDF (formerly python-fitz), a Python binding which supports MuPDF 1.9a - “a lightweight PDF and XPS viewer”.
MuPDF can access files in PDF, XPS, OpenXPS and EPUB (e-book) formats, and it is known for its top performance and high rendering quality.
With PyMuPDF you therefore can also access files with extensions *.pdf, *.xps, *.oxps or *.epub from your Python scripts.
See the Wiki for more info/news/release notes/etc.
You need to have MuPDF v1.9a generated first. This process depends on your platform, see below. MuPDF’s source comes with installation procedures for various operating systems, so you should be able to pick the right one for you. Linux versions also often provide pre-generated MuPDF software.
Once this is done, the rest should be as easy as running python setup.py install.
Refer to this document for details.
Since MuPDF v1.9a is not available yet in the official repo, you need to first build it from source. Make sure to add -fPIC to CFLAGS when compiling.
When MuPDF is ready, edit setup.py in PyMuPDF and comment out the line of library_dirs= to specify the directory which contains libmupdf.a and other 3rd party libraries. Remove crypto from libraries in setup.py if it complains.
First please make sure that the dependencies are satisfied: brew install mupdf-tools jpeg jbig2dec freetype openssl
Then you might need to export ARCHFLAGS='-arch x86_64' since libmupdf.a is for x86_64 only.
Finally, please double check setup.py before building. Update include_dirs and library_dirs if necessary.
We have prepared pre-generated binaries here, that are suitable for your Python version. Using this option avoids downloading anything else and requires no compiler nor Visual Studio. Please refer to this document for details.
You can also directly download your binary (less than 5 MB each) from one of the following GitHub links:
If you however want to make your own binary, have a look at this Wiki page. It explains how to use Visual Studio for generating MuPDF in some detail. This is also the way, how the pre-generated binaries have been created.
You can render supported documents, extract text in a variety of formats, access meta information, table of contents and other links, and (PDF only) decrypt, compress / decompress files, re-arrange / duplicate / delete pages, join documents or update meta information and bookmarks.
The underlying graphics library also offers a range of very fast image handling functions that can be used independently from dealing with document files.