39.4 Python

There are 2 sets of Python bindings for MuPDF.

The first set is an independent open source project called PyMuPDF (https://pypi.org/project/PyMuPDF/). This was developed independently of MuPDF, but support and commercial licensing options are now available through Artifex if required. This is a mature set of code with some helpful extensions to MuPDF itself over and above a raw reflection of the C API. We will say no more about this set of bindings here.

The second set of bindings are newer, and developed directly by the MuPDF developers themselves. They consist of a reflection of the C API (actually, a reflection of the C++ API, which is itself a reflection of the C API) into Python.

For the technically inclined, these bindings are generated programmatically from the C++ API using SWIG (http://swig.org). The C++ mupdf namespace is reflected into a Python module called mupdf.

Thus, any changes to the C API that survive the conversion into the C++ API should make it into the Python API automatically.

As a demonstration both of the power of the Python bindings and a test of them (and indirectly the C++ ones on which they are based) we have converted the draw subtool from mutool to python as scripts/mutool_draw.py.