NexPDF for Node.js
Render, extract, edit, convert, sign and OCR PDFs in Node.js, Deno and Bun with the NexPDF engine running in-process through WebAssembly.
NexPDF for Node.js (@nexdevit/nexpdf-node) runs the NexPDF engine in-process through WebAssembly.
There is no native addon and no server, and the same build runs on Linux, macOS, Windows and
serverless platforms. It also works in Deno and Bun.
import { PdfDocument } from '@nexdevit/nexpdf-node';
const doc = await PdfDocument.open('contract.pdf');
console.log(doc.pageCount, doc.pageSize(0));
console.log(doc.text(0));
doc.close();Requirements
| Node.js | 18 or later (ES modules, or require for the engine) |
| Operating systems | Any platform Node.js runs on: the engine is WebAssembly |
| Engine | wasm/ from the release (nexpdf-wasm-node-1.1.0.tar.gz) |
| Dependencies | None |
How it works
PdfDocumentis a convenience wrapper with camelCase methods and parsed JSON results.doc.rawis the underlyingWasmDocument, with every function of the C SDK and the same JSON options as every NexPDF SDK.- Byte buffers are
Uint8Array; aBufferfromfsworks as is. Rectangles are PDF user space,[llx, lly, urx, ury], in points with the origin at the bottom-left of the page. - A failed call throws an
Errorwith the engine's message, for example when the license does not include the module a call needs. - Calls are synchronous and run on the calling thread. For parallel work, open documents in
worker_threads; each worker loads its own engine and needs its ownactivateLicensecall. - Call
doc.close()when you are done with a document to free its WebAssembly memory. - The Tesseract OCR engine and the TSA, OCSP and CRL network calls are not available under WebAssembly. Use the built-in OCR engine, or a native SDK such as Python for those.
Getting started
Installation
Add the package and the WebAssembly engine.
Your first document
Open a PDF, render a page and extract its text.
Add your license key
Activate a key and handle license errors.
Running without a key
View-only mode, the watermark and trial keys.
Guides
Opening and saving
Files, bytes, passwords, pictures, HTML, Office and e-book input.
Rendering
Pages and thumbnails to PNG, coordinates.
Document structure
Metadata, bookmarks, page labels, layers, attachments.
Text extraction
Text, Markdown, positioned blocks, passages for LLMs.
Search
Find text and its rectangles.
OCR
Make scanned pages searchable with the built-in engine.
Structured extraction
Tables, key-values, schema extraction with your LLM, classification.
Barcodes
Read QR, Data Matrix, PDF417 and linear codes; draw barcodes.
Annotations
Markup, shapes, ink, stamps, measurements, XFDF.
Forms
Fill, create, calculate, flatten, import and export.
XFA forms
Run FormCalc and JavaScript, lay out dynamic forms, convert to AcroForm, flatten.
Comment threads
Replies and review states on annotations.
Real-time collaboration
The NexPdfSync client: live pages, annotations, comments, form values, presence.
Editing
Merge, split, reorder, crop; edit text and images.
Compare and optimise
Diff versions, shrink files, watch memory.
Word-level comparison
Inserted, deleted, replaced and moved text; annotated PDF.
Security
Encryption, permissions, watermarks, Bates numbers.
Redaction
Remove content for good by area, text or pattern.
Signatures
PAdES signing with a PKCS#12 file or an external signer, verification.
Long-term signatures
Signature levels, document timestamps, verifying B-LTA.
Conversion
PDF to Word, Excel, PowerPoint, HTML and more.
Templates
PDFs from Word, HTML and PDF templates and JSON data.
PDF/A, PDF/X and PDF/UA
Archiving, print and accessibility.
PDF/A and PDF/UA validation
PDF/A and PDF/UA-1 and -2 with clause ids; convert to PDF/A or PDF/UA.