Skip to Content
NexPDF

Installation

Install the NexPDF Python package and make the native engine library available.

English

Install the package

pip install nexdevit-nexpdf

The package is imported as nexpdf.

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:

PlatformArchiveLibrary
Linux x86_64nexpdf-ffi-1.1.0-linux-x64.tar.gzlib/libnexpdf_ffi.so
Linux arm64nexpdf-ffi-1.1.0-linux-arm64.tar.gzlib/libnexpdf_ffi.so
macOSnexpdf-ffi-1.1.0-macos-universal.tar.gzlib/libnexpdf_ffi.dylib
Windows x86_64nexpdf-ffi-1.1.0-windows-x64.ziplib/nexpdf_ffi.dll

Tell the SDK where the library is

The library is looked up in this order:

  1. nexpdf.load_library(path), called before any other NexPDF call;
  2. the NEXPDF_LIB_PATH environment variable (the full path of the file);
  3. the NEXPDF_LIB_DIR environment variable (the folder holding it);
  4. nexpdf/lib/ inside the installed package;
  5. the system loader (LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, PATH).
export NEXPDF_LIB_PATH=/opt/nexpdf/lib/libnexpdf_ffi.so

or, 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-python

Docker

Dockerfile
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

On this page