PyMuPDF is a Python binding for the PDF rendering library MuPDF
Release date: December, 2016
This is version 1.10.0 of PyMuPDF (formerly python-fitz), a Python binding which supports MuPDF 1.10a - “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.10 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.10 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 binaries here, that are suitable for your Python version. Using this option avoids downloading anything else and requires no compiler or Visual Studio. Please refer to this document for details.
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.
Usage and Documentation
You can render supported documents, extract text in a variety of formats, access annotations, links, meta information, table of contents, and (PDF only) decrypt, compress / decompress files, re-arrange / duplicate / delete pages, join documents or update meta information, annotations and bookmarks.
The underlying graphics library also offers a range of very fast image handling functions which can be used independently from dealing with document files, and which also easily interface with other Python graphics libraries like PIL
You have a number of options to access documentation: