Installation
Install the NexPDF Python package and make the native engine library available.
Get the native library
A platform wheel ships the engine in nexpdf/lib/. Otherwise download the archive for your platform
from the v1.1.0 release:
| Platform | Archive | Library |
|---|---|---|
| Linux x86_64 | nexpdf-ffi-1.1.0-linux-x64.tar.gz | lib/libnexpdf_ffi.so |
| Linux arm64 | nexpdf-ffi-1.1.0-linux-arm64.tar.gz | lib/libnexpdf_ffi.so |
| macOS | nexpdf-ffi-1.1.0-macos-universal.tar.gz | lib/libnexpdf_ffi.dylib |
| Windows x86_64 | nexpdf-ffi-1.1.0-windows-x64.zip | lib/nexpdf_ffi.dll |
Tell the SDK where the library is
The library is looked up in this order:
nexpdf.load_library(path), called before any other NexPDF call;- the
NEXPDF_LIB_PATHenvironment variable (the full path of the file); - the
NEXPDF_LIB_DIRenvironment variable (the folder holding it); nexpdf/lib/inside the installed package;- the system loader (
LD_LIBRARY_PATH,DYLD_LIBRARY_PATH,PATH).
export NEXPDF_LIB_PATH=/opt/nexpdf/lib/libnexpdf_ffi.soor, in code:
import nexpdf
nexpdf.load_library("/opt/nexpdf/lib/libnexpdf_ffi.so")Check the installation
python -c "import nexpdf; print(nexpdf.version())"Building a wheel with the engine inside
To ship one self-contained wheel per platform, copy the library into the package before building:
libnexpdf_ffi.so
__init__.py
pyproject.toml
python -m build nexpdf-pythonDocker
FROM python:3.12-slim
ADD https://github.com/nexdevit/nexpdf-python/releases/download/v1.1.0/nexpdf-ffi-1.1.0-linux-x64.tar.gz /tmp/
RUN tar -xzf /tmp/nexpdf-ffi-1.1.0-linux-x64.tar.gz -C /opt && pip install nexdevit-nexpdf
ENV NEXPDF_LIB_DIR=/opt/nexpdf-ffi-1.1.0-linux-x64/lib