Troubleshooting
Fixes for the most common problems with NexPDF for the web - the WebAssembly module not loading, bundlers, license and watermark issues, fonts, signatures, OCR, XFA, PDF/A, sync and memory.
The module was not found where it was fetched from. By default loadNexPdf() fetches
nexpdf_bg.wasm next to the package's wasm/nexpdf.js, which Vite and other bundlers that handle
new URL(..., import.meta.url) resolve on their own. Check that the wasm/ folder from the release
is inside the package (see Installation). If your setup serves the file
from somewhere else, copy it to your static folder and pass its URL:
const nex = await loadNexPdf('/assets/nexpdf_bg.wasm');After a failed load, loadNexPdf() keeps returning the same rejected promise until the page reloads.
The module still loads, but more slowly: the browser cannot compile it while it downloads. Configure
your server or CDN to send .wasm files with Content-Type: application/wasm.
The package entry points are TypeScript sources (src/*.ts). Use a bundler that compiles
TypeScript in dependencies, such as Vite, Next.js, Nuxt, Angular CLI or SvelteKit. The engine must
run in the browser: in Next.js and Nuxt, load it from client-side code only (a 'use client'
component, or a dynamic import inside an effect), never during server rendering.
Check what nex.licenseStatus() returns in the page or worker that renders:
unlicensed:activateLicensewas never called in this engine, or it threw. Each page load and each Web Worker 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 image served from a cache.
Web keys are bound to host names. activateLicense(key, location.hostname) passes the host the page
runs on, for example app.example.com; the key must list it, or a wildcard such as
*.example.com. Preview and staging hosts need to be on the key too. You can change the hosts in
the dashboard and download a re-signed key.
The engine checks keys for platform web. A key for server, android or ios is rejected. Ask
for a web key for the browser engine. The viewer is different: it runs on the
WebViewer server and needs a server key there.
In the browser, the key is checked against the clock of the user's device. A device whose clock is far off can reject a valid key. The page keeps working in view-only mode; ask the user to correct the date and time, and reload.
nexpdf_lite_bg.wasm has no bundled fonts. Documents that use a standard font (Helvetica, Times,
Courier) without embedding it need substitutes registered before they are opened:
if (!nex.hasBundledFonts()) await nex.loadStandardFonts('/fonts/');loadStandardFonts fetches the twelve Liberation .ttf files from that folder; see
Installation. PDF/A conversion needs them too.
Since 1.1, PdfDocument.fromBytes, fromFile and fromUrl recognise e-books, XPS files and comics
and convert them with the e-book converter. Update the package and the wasm/ folder together: an
older module sends every ZIP-based file to the Office converter. nex.detectKind(bytes) shows which
converter a file goes to, and nex.PdfDocument.fromEbook(bytes) 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 returns the complete signed file. Keep those bytes unchanged. Calling toBytes() or
toBlob() on the document afterwards rewrites the file and invalidates the signature. See
Signatures.
sign 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 }),
nex.completeExternalSignatureOnline, nex.timestampSignature, nex.addLtvOnline and
nex.timestampDocument. When they fail:
- A network error, no HTTP status: the browser blocked a cross-origin request. Most public TSA
and OCSP servers do not allow CORS. Pass a
fetchthat goes through your own server, or atsafunction that gets the time-stamp itself. - "answered HTTP …": the TSA, OCSP or CRL server refused the request; check the URL and any
headers(such asAuthorization) it 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.
Tesseract is not available in the browser. ocr() uses the built-in engine; loaded neural models
are used through doc.raw.ocr. See OCR.
The built-in engine reads Latin-script text only. Load neural models for other scripts with
nex.wasm.ocrLoadModel (a detection model and a recognition model with its dictionary), then call
doc.raw.ocr(JSON.stringify({ engine: 'auto', languages: 'ara' })); doc.ocr() always uses the
built-in engine. The lighter module has no neural engine, so use the standard module. 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, or use the session URL (https://host/s/<id>) in a page that holds the session cookie,
with credentials: 'include' when the server is on another site. See
Real-time collaboration.
Engine calls are synchronous and run on the thread that calls them. ocr(), conversions and
high-resolution renders of large documents block the main thread until they finish. Run the engine in
a Web Worker; see Platform notes.
Call doc.close() on every document you no longer need, and revoke the object URLs from
renderUrl with URL.revokeObjectURL. After very large edits, doc.trimMemory() compacts what a
document holds. See Platform notes.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.