This repository contains Dlang bindings for MuPDF and tools to auto-generate them for arbitrary versions.
-
Build and install from MuPDF sources, or alternatively:
sudo apt install -y libmupdf-dev
-
Add the package via DUB:
dub add mupdf
-
Import the package, and follow the MuPDF API documentation as needed, e.g.:
import mupdf; void main() { auto ctx = fz_new_context(null, null, FZ_STORE_UNLIMITED); auto doc = pdf_open_document(ctx, "path/to/file.pdf"); // ... }
Note the following remarks:
- All
PDF_NAME(x)
macro invocations must be replaced withPDF_NAME_x
shorthands.
Current known limitations of these bindings:
- Only POSIX support for now.
- Many helper functions defined via preprocessor macros are not available.
- Exceptions via
fz_try
,fz_always
,fz_catch
are not supported.
To generate Dlang bindings for an arbitrary version of MuPDF:
-
Run the script
generate.sh
and follow usage instructions, e.g. to generate bindings for mupdf-1.19.0 run the following command:./generate.sh 1.19.0