Skip to Content
NexPDF

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.

English

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.js18 or later (ES modules, or require for the engine)
Operating systemsAny platform Node.js runs on: the engine is WebAssembly
Enginewasm/ from the release (nexpdf-wasm-node-1.1.0.tar.gz)
DependenciesNone

How it works

  • PdfDocument is a convenience wrapper with camelCase methods and parsed JSON results. doc.raw is the underlying WasmDocument, with every function of the C SDK and the same JSON options as every NexPDF SDK.
  • Byte buffers are Uint8Array; a Buffer from fs works 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 Error with 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 own activateLicense call.
  • 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

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.

Help and reference

On this page