Auto-generated mupdf C++ wrappers


As of 2020-4-28:

  • We generate class wrappers for all fz structs.
  • We auto-detect fz_*() fns suitable for wrapping as constructors, methods or static methods.
  • Some generated classes have auto-generated support for iteration.
  • We add various custom wrappers for fz_*() fns.
  • We add various custom methods/constructors.
  • We provide access via wrapper classes to 686 fz_*() fns.
  • There are a total of 888 fz_*() functions. Most of the omitted functions don't take struct args, e.g. fz_strlcpy(). Of the remaining, some use fz_* enums (which we don't yet wrap); see for more information.
  • We work with swig-3 or swig-4.
  • We work with clang-6 or clang-7.
  • We work on peeved and jules-laptop.


  • We use clang to extract doxygen-style comments, and propogate them into generated header files.
  • If swig is version 4+, we tell it to propogate comments into generated

Here are Doxygen html representations of the mupdf C API and the generated mupdf C++ API:

And pydoc html representation of the generated API:


Auto-generated C++ headers and implementation files, plus test outputs (.html files have syntax-colouring):

Information about fz_*() fns that are not in the class-based API:

These were generated by the programme, which also runs g++ and SWIG to generate a Python module that gives a Python API:

The generated Python module is tested by the (rather hacky) test_mupdfcpp_swig() function in For convenience, this function and its output can be viewed in


  • See "Todo:" section in comment near top, for status of various todo items.

Integration with mupdf git.

In mupdf, have added various things:

        [generated file]
       [generated file, implements C++ API]
        [generated file]
       [generated file, implements C++ API]
                    *.cpp [generated files]
                        *.h [generated files]
       [generated file, implements Python API]
       [generated file, implements Python API internals]


To build:

    cd mupdf/
    ./scripts/ -b all -t

Have also added crude support for building mupdf as a shared object, which is required for integrating with the SWIG python module. At the moment, drives this to build

-- Julian Smith - 2020-03-04


This topic: Main > UserList > JulianSmith > MupdfCppWrappers
Topic revision: r16 - 2020-04-27 - JulianSmith
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 2014 Artifex Software Inc