PyMuPDF is a Python binding for the PDF rendering library MuPDF
Release date: May 1, 2017
This is version 1.11.0 of PyMuPDF (formerly python-fitz), a Python binding which supports MuPDF 1.11 - “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 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.
For Non-Windows systems, probably the safest way is to generate MuPDF from source. Download the official release from https://mupdf.com/downloads/. MuPDF’s GitHub repository contains the latest development source - this is not what you want in this context. Make sure PyMuPDF already supports this MuPDF version, otherwise skip to an earlier release: https://mupdf.com/downloads/archive/.
Once this is done, adjust directories in setup.py and the rest should be as easy as running python setup.py install.
Refer to this document for more details: http://pythonhosted.org/PyMuPDF/installation.html.
Since MuPDF’s current releases are often delayed in the official repo, you need to build it from source as indicated above. 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.
Also do have a look at the respective Wiki in PyMuPDF’s GitHub repository.
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 where necessary.
We have prepared binaries here, that are suitable for your Windows / Python configuration (32bit / 64bit, Py 2.7 and up, Windows XP and up). Using this option requires downloading the correct 3 MB zip file and nothing else - no MuPDF source / generation, no compiler nor Visual Studio. Please refer to the above mentioned installation instructions.
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 our binaries have been created.
Usage and Documentation
You can render page images and extract text from a variety of document types.
For PDF, a broad range of modifications is also possible, including annotations, links, meta information, table of contents, decryption, (de-) compression, joining or splitting files, re-arranging, duplicating, deleting, creating or watermarking pages. The current version 1.11.0 also has added support for PDF embedded files.
The underlying graphics library also offers a range of very fast image handling functions which can be used independently from dealing with documents, and which also easily interface with other Python graphics libraries like PIL / Pillow.
You have a number of options to access documentation (made using Sphinx):