Troubleshooting
Fixes for the most common problems with NexPDF for Java - the native library not loading, license and watermark issues, fonts, signatures and OCR.
JNA found no native engine. It looks, in this order, at -Dnexpdf.library.path or
NEXPDF_LIB_PATH (the full path of the file), jna.library.path (a folder), the system library
path, and the <platform>/ folders inside the jar. Point it at the file:
java -Dnexpdf.library.path=/opt/nexpdf/lib/libnexpdf_ffi.so -jar app.jarThe property and the variable are used only when they name an existing file. A wrong path is
ignored silently and the search goes on, so check it with ls. The library must also match the
JVM's architecture (java -XshowSettings:properties -version 2>&1 | grep os.arch): an arm64 library
does not load in an x86_64 JVM. See Installation.
The library failed to load on an earlier call (look for the first UnsatisfiedLinkError in the
log). The JVM does not retry a class that failed to initialise, so fix the library path and restart
the process.
The native library is older than the jar. Use the library from the same release as the
com.nexdevit:nexpdf version in your build, and check that no older copy sits earlier on
jna.library.path or the system path. NexPdf.version() prints the version of the library that
was loaded.
Recent JDKs warn when a library loads native code through JNI, as JNA does. The SDK's own tests run with the flag that allows it:
java --enable-native-access=ALL-UNNAMED -jar app.jarFiles downloaded with a browser get the quarantine attribute. Remove it from the library you extracted:
xattr -d com.apple.quarantine /opt/nexpdf/lib/libnexpdf_ffi.dylibThe Linux release libraries are built on Ubuntu 22.04 (glibc 2.35) and can fail to load on older
systems. Use a newer base image (for example eclipse-temurin:21-jre, based on Ubuntu) or
distribution. There is no musl build, so Alpine images need a glibc-based image instead.
Check what NexPdf.licenseStatusJson() returns in the process that renders:
unlicensed:activateLicensewas never called in this JVM, or it threw. Activate it at start-up, before the first document is opened, in every JVM that renders.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. On servers use
platform server 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.isLicensed("xyz") to hide the feature.
The PDF uses a standard font (Helvetica, Times, Courier) without embedding it. The default build
bundles the Liberation fonts as substitutes. If NexPdf.hasBundledFonts() returns 0, register
them yourself:
for (String name : List.of("LiberationSans-Regular.ttf", "LiberationSerif-Regular.ttf", "LiberationMono-Regular.ttf")) {
NexPdf.registerStandardFont(Files.readAllBytes(Path.of(name)));
}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 as a byte[]. 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. See
OCR.
The built-in engine reads Latin-script text only. Load a detection model and a recognition model
for the script with NexPdf.ocrLoadModel before calling ocr, and pass matching languages.
NexPdf.ocrModelsJson() 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
xfaToAcroform() or xfaFlatten(); 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
NexPdfException message lists their clauses. Run validatePdfaJson(level) to see each failure
with its page and object. See PDF/A and PDF/UA validation.
Documents live in native memory, outside the Java heap, so -Xmx does not limit them and heap
dumps do not show them. Close every document (try-with-resources): the Cleaner frees forgotten
ones only after a garbage collection, which a large heap may delay. Leave room for native memory in
container limits, and see Compare and optimise.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.