Troubleshooting
Fixes for the most common problems with NexPDF for Node.js - the WebAssembly engine not loading, bundlers and serverless packaging, license and watermark issues, fonts, signatures, OCR, XFA, PDF/A, sync and memory.
The package was installed without its engine. The WebAssembly files are distributed separately:
extract nexpdf-wasm-node-1.1.0.tar.gz into the package so that it has a wasm/ folder with
nexpdf.js and nexpdf_bg.wasm, then install it again. See
Installation.
The engine reads nexpdf_bg.wasm from the folder of wasm/nexpdf.js when the package is imported.
This happens when a bundler (esbuild, webpack, Rollup) inlined the JavaScript into your bundle but
left the .wasm file behind. Mark the package as external so it stays in node_modules:
esbuild server.mjs --bundle --platform=node --format=esm --external:@nexdevit/nexpdf-nodeand ship node_modules/@nexdevit/nexpdf-node with the function, including wasm/.
Since 1.1 the package also has a CommonJS entry: require('@nexdevit/nexpdf-node') loads the same
engine (document.cjs) and works in CommonJS hosts such as the Electron main process. The error
means an older package is installed; update it. @nexdevit/nexpdf-node/sync and
@nexdevit/nexpdf-node/client are ES modules only: load them with import or
await import(...).
Check what licenseStatus() returns in the process or worker that renders:
unlicensed:activateLicensewas never called in this engine, or it threw. Each process and eachworker_threadsworker has its own engine; activate the key in every one of them.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 Node.js SDK runs the WebAssembly engine, which checks keys for platform web. A server key
issued for the native SDKs is rejected. Ask for a web key whose host is your app id. See
License.
The appId you passed is not the one the key was issued for. Without the argument it is
nexpdf-node. Pass the app id from the key, character for character. You can change it 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 check licenseStatus().modules to hide the feature.
The PDF uses a standard font (Helvetica, Times, Courier) without embedding it. The Node.js engine bundles the Liberation fonts as substitutes, so this should not happen with the release module. If you built a module without them, rebuild it with the default features.
Since 1.1, PdfDocument.open and PdfDocument.fromBytes recognise e-books, XPS files and comics and
convert them with the e-book converter. Update the package and its wasm/ folder together: an older
engine sends every ZIP-based file to the Office converter. detectKind(bytes) shows which converter a
file goes to, and PdfDocument.fromEbook(source) forces the e-book converter; see
Opening and saving.
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.
sign and signTest return the complete signed file. Write those bytes to disk unchanged. Calling
doc.save() afterwards rewrites the file and invalidates the signature. See
Signatures.
sign, addLtv and doc.raw.addDocumentTimestamp make no network calls, so tsa_url, ltv and
levels B-T, B-LT and B-LTA fail there. Use the online calls, which get the time-stamps and OCSP
and CRL data with fetch: await doc.signOnline(p12, password, { level, tsaUrl }),
completeExternalSignatureOnline, timestampSignature, addLtvOnline and timestampDocument.
When they fail:
- A network error: the machine cannot reach the TSA, OCSP or CRL server (firewall, proxy). Pass
a
fetchthat goes through your proxy. - "answered HTTP …": the server refused the request; check the URL and any
headers(such asAuthorization) the TSA needs. - "TSA callback failed": your
tsafunction threw, or returned no response bytes. - "level B-T needs tsaUrl (or a tsa function)": B-T and B-LTA need a time-stamp authority.
See Long-term signatures.
Only the built-in OCR engine runs under WebAssembly, even when tesseract is installed on the
machine. engine: 'auto' uses loaded neural models or the built-in engine. For Tesseract, use a
native SDK such as Python.
The built-in engine reads Latin-script text only. Load neural models for other scripts with
ocrLoadModel (a detection model and a recognition model with its dictionary) in the same process
or worker, then call doc.ocr({ languages: 'ara' }) with engine left at auto. See
OCR.
The file is a dynamic XFA form, which most viewers no longer lay out. Convert it with
doc.raw.xfaToAcroform() or doc.raw.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 message
lists their clauses. Run doc.raw.validatePdfaJson(level) to see each failure with its page and
object. See PDF/A and PDF/UA validation.
The server refused the stream: a missing or expired session token (401), no access to the session
(403), a session that does not exist (404) or a server without a license for sync (402). The client
does not retry these and closes. Pass a valid token; see
Real-time collaboration.
Engine calls are synchronous and block the event loop until they finish. Run OCR, conversions and
large renders in a worker_threads worker or a job queue; see
Platform notes.
Call doc.close() on every document, in a finally block. After very large edits,
doc.trimMemory() compacts what a document holds. WebAssembly memory is not given back to
the operating system while the engine is loaded. See
Platform notes.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.