Troubleshooting
Fixes for the most common problems with NexPDF for C and C++ - finding and linking the native library, loading it at run time, license and watermark issues, fonts, signatures and OCR.
find_library found no libnexpdf_ffi in NEXPDF_LIB_DIR. Point it at the lib/ folder of the
extracted release archive, or pass the archive folder itself as NEXPDF_ROOT:
cmake -S . -B build -DNEXPDF_LIB_DIR=/opt/nexpdf-ffi-1.1.0-linux-x64/lib
# or
cmake -S . -B build -DNEXPDF_ROOT=/opt/nexpdf-ffi-1.1.0-linux-x64Both are cache variables: a value from an earlier configure run wins over a new environment
variable. Pass the new value with -D, or delete build/CMakeCache.txt and configure again.
NEXPDF_ROOT is supported from 1.0.1.
The C header is not on the include path. With CMake, link the nexdevit::nexpdf target, which adds
both include folders. Without CMake, add the include/ folder of nexpdf-cpp (for nexpdf.hpp)
and the archive's include/ folder (for nexpdf.h) with -I.
The header and the library come from different releases: a newer header declares a function the
older library does not have. Use the nexpdf-cpp version that matches the archive.
With the static library and your own build system, undefined references to dlopen,
pthread_* or Security framework symbols mean the system libraries are missing. Link pthread,
dl and m on Linux, -framework Security -framework CoreFoundation on macOS, and ws2_32,
userenv, bcrypt, ntdll, advapi32, crypt32 and secur32 on Windows. The CMake target adds
them when NEXPDF_STATIC=ON. See Installation.
The program was linked against the shared library but cannot find it at run time. Add an rpath to
the folder where you install it (-Wl,-rpath,<folder>, or INSTALL_RPATH in CMake), set
LD_LIBRARY_PATH, or link the static library with -DNEXPDF_STATIC=ON.
The library's install name is @rpath/libnexpdf_ffi.dylib, so the program needs an rpath to its
folder, for example @executable_path when you ship the library next to the executable. See
Installation. If macOS blocks a
library you downloaded with a browser, remove the quarantine attribute:
xattr -d com.apple.quarantine /opt/nexpdf-ffi-1.1.0-macos-universal/lib/libnexpdf_ffi.dylibLink the import library nexpdf_ffi.dll.lib and put nexpdf_ffi.dll next to the executable (or in
a folder on PATH). Windows has no rpath, so the DLL must be copied there, for example with a
post-build copy step. The static nexpdf_ffi.lib avoids the DLL.
The Linux release libraries are built on Ubuntu 22.04 (glibc 2.35) and can fail to load on older
systems. Build and run on a newer distribution or base image, for example Ubuntu 22.04 or
Debian 12. There is no musl build, so Alpine images need a glibc-based image instead. The static
library removes the dependency on libnexpdf_ffi, not on glibc.
The Document was moved into another variable, or reset() freed it. A moved-from document holds
no handle; use the object it was moved into, or check if (doc) before using it.
Check what nexpdf::license_status_json() returns in the process that renders:
unlicensed:activate_licensewas never called in this process, or it threw. Call it at start-up and catchnexpdf::Errorto log the reason.trial: trial keys always keep the "NexPDF • Trial" watermark.licensed: commercial keys render without a watermark. If you still see one, it is an old render served from a cache.
The key does not list the platform (-6) or application id (-7) you passed. Use the platform the
key was issued for (server, linux, macos or windows) and the app id registered for the
license, character for character. You can change both in the dashboard and download a
re-signed key.
The machine's clock is earlier than the key's issue date. Fix the clock (NTP) and activate again.
Your plan does not include that module. See Modules and tiers for which
plan unlocks it, and use nexpdf::is_licensed("xyz") to hide the feature.
In 1.0.0, Document::open and open_bytes sent every ZIP-based file to the Office converter.
1.0.1 detects e-books and comics and converts them. On 1.0.0, call nexpdf::open_ebook(data)
directly. In C, nexpdf_open_bytes opens PDFs and pictures only: call nexpdf_open_office or
nexpdf_open_ebook yourself for other formats.
The PDF uses a standard font (Helvetica, Times, Courier) without embedding it. The default build
bundles the Liberation fonts as substitutes. If nexpdf::has_bundled_fonts() returns 0, register
them yourself:
for (const char* path : {"LiberationSans-Regular.ttf", "LiberationSerif-Regular.ttf", "LiberationMono-Regular.ttf"}) {
nexpdf::register_standard_font(read_file(path));
}The page is a scanned image with no text layer. Run OCR first; it adds an invisible text layer that extraction and search then read.
Signing returns the complete signed file. Write those bytes to disk unchanged. Calling doc.save()
afterwards rewrites the file and invalidates the signature. See
Signatures.
With "engine": "auto", Tesseract is used only when the tesseract program is on PATH and has
data for every requested language. Check with tesseract --list-langs, or pass
"engine": "tesseract" to get an error instead of the fallback.
The built-in engine reads Latin-script text only. Load a detection model and a recognition model
for the script with nexpdf::ocr_load_model before calling ocr, and pass matching languages.
nexpdf::ocr_models_json() lists what is loaded; the report's engine says neural (<name>) when a
model was used. See OCR.
The file is a dynamic XFA form, which most viewers no longer lay out. Convert it with
xfa_to_acroform() or xfa_flatten(); see XFA forms. Scripts in
the form (FormCalc, JavaScript) are not run.
The document was converted as far as possible, but some PDF/A rules still fail; the error lists
their clauses. Run validate_pdfa_json(level) to see each failure with its page and object. See
PDF/A and PDF/UA validation. In C, nexpdf_convert_pdfa_level
returns 0 and nexpdf_last_error() holds the list.
Make sure every Document goes out of scope or is reset(), and in C that every result is freed
with nexpdf_free_string, nexpdf_free_bytes or nexpdf_free. Documents that stay open for a
long time can call trim_memory() after large operations. See
Compare and optimise.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.