Troubleshooting
Fixes for the most common problems with NexPDF for PHP - the FFI extension, loading the native library, PHP-FPM workers, license and watermark issues, fonts, signatures and OCR.
The FFI extension is not installed or not enabled. Install it (for example docker-php-ext-install ffi in the official PHP images, or your distribution's php-ffi package), enable it in
php.ini and check:
php -m | grep FFIThe web server's PHP can use a different php.ini from the CLI; check with phpinfo() there too.
The default ffi.enable=preload allows FFI only in the CLI and in preloaded scripts, so scripts
work from the command line but fail under PHP-FPM or Apache. Set it in the php.ini of the web
server and restart it:
ffi.enable=trueNo path candidate pointed at an existing file, so the SDK asked the system loader for the bare file name and it found nothing. Point the SDK at the library:
export NEXPDF_LIB_PATH=/opt/nexpdf-ffi-1.1.0-linux-x64/lib/libnexpdf_ffi.soor call Nexdevit\NexPdf\Native::load('/path/to/libnexpdf_ffi.so') before any other NexPDF call.
Check the file matches the architecture of the PHP binary: an arm64 library does not load in an
x86_64 PHP. See Installation.
Besides ffi.enable, PHP-FPM clears the environment of its workers by default
(clear_env = yes), so NEXPDF_LIB_PATH and NEXPDF_LICENSE_KEY from your shell or container do
not reach PHP. Pass them in the pool configuration:
env[NEXPDF_LIB_PATH] = /opt/nexpdf-ffi-1.1.0-linux-x64/lib/libnexpdf_ffi.so
env[NEXPDF_LICENSE_KEY] = NEX2....or call Native::load($path) in your bootstrap code.
The package declares a function the loaded library does not have: the library is older than the package. Use the library from the release that matches the package version.
Files downloaded with a browser get the quarantine attribute. Remove it from the library you extracted:
xattr -d com.apple.quarantine /opt/nexpdf-ffi-1.1.0-macos-universal/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 php:8.3-cli or php:8.3-fpm, based on Debian 12) or
distribution. There is no musl build, so php:*-alpine images need a Debian-based image instead.
Check what NexPdf::licenseStatus()['state'] returns in the request that renders:
unlicensed:activateLicensewas not called in this PHP process, or it threw. Each PHP-FPM worker is a separate process: activate the key in your bootstrap code, which runs in every worker.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 document was closed with close() before this call. Close documents only when you are done
with them. isClosed() tells whether a document is still open.
In 1.0.0, Document::open and Document::openBytes 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::openEbook($data) directly.
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:
foreach (['LiberationSans-Regular.ttf', 'LiberationSerif-Regular.ttf', 'LiberationMono-Regular.ttf'] as $path) {
NexPdf::registerStandardFont(file_get_contents($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 as a binary string. Write it to disk unchanged with
file_put_contents. 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 the PATH of
the PHP process and has data for every requested language. Check with tesseract --list-langs as
the user PHP-FPM runs as, 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::ocrLoadModel before calling ocr, and pass matching languages.
Models are loaded per process, so under PHP-FPM every worker must load them. 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 error lists
their clauses. Run validatePdfaJson($level) to see each failure with its page and object. See
PDF/A and PDF/UA validation.
In queue workers and other long-running scripts, call close() on every document when you are done
instead of waiting for the object to be destroyed. Documents that stay open for a long time can
call trimMemory() after large operations. See
Compare and optimise.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.