NexPDF for the web
Open, render, edit, sign and convert PDFs in the browser with the NexPDF WebAssembly engine, or embed the ready-made NexPDF viewer in React, Vue, Angular and Svelte apps.
NexPDF for the web (@nexdevit/nexpdf-web) comes in two parts:
- The engine,
@nexdevit/nexpdf-web/engine, is the whole NexPDF SDK compiled to WebAssembly. It opens, renders, edits, signs and converts documents inside the page, with no server, so documents never leave the device. - The viewer,
@nexdevit/nexpdf-weband its framework components, embeds the ready-made NexPDF reader and editor. The viewer runs in an iframe served by the NexPDF WebViewer server and is driven throughpostMessage.
import { loadNexPdf } from '@nexdevit/nexpdf-web/engine';
const nex = await loadNexPdf();
const doc = await nex.PdfDocument.fromUrl('/contract.pdf');
console.log(doc.pageCount, doc.pageSize(0));
console.log(doc.text(0));
img.src = doc.renderUrl(0, { dpi: 110 });Requirements
| Engine | A browser with WebAssembly and ES modules |
| Viewer | A running NexPDF WebViewer server, reachable from the page and allowed to be framed by its origin |
| Bundler | One that compiles TypeScript: the package entry points are .ts sources (Vite, Next.js, Nuxt, Angular CLI, SvelteKit) |
| Svelte component | svelte 4 or later (an optional peer dependency) |
How it works
loadNexPdf()instantiates the WebAssembly module once and returns the same engine on every later call.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. 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. - Call
doc.close()when you are done with a document to free its WebAssembly memory.
Getting started
Installation
Add the package and the WebAssembly module to your app.
Your first document
Open a PDF, render a page and extract text in the browser.
Add your license key
Activate a web key bound to your domain.
Running without a key
View-only mode, the watermark and trial keys.
Viewer
Embed the ready-made viewer in your framework.
Guides
Opening and saving
Files, URLs, 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 in the browser.
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
Fill PDF templates from 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.