NexPDF for Electron
Add the complete NexPDF reader and editor to an Electron desktop app, powered by the native NexPDF engine running as a local helper process, and work with documents in the main process.
NexPDF for Electron (@nexdevit/nexpdf-electron) puts the complete NexPDF reader and editor in a
desktop window: annotations, forms, signatures, redaction, the page organiser, conversion, the
assistant and comments. The native NexPDF engine runs as a helper process on a random loopback port,
and a BrowserWindow shows the same interface as the web viewer.
const { app } = require('electron');
const { openPdfWindow } = require('@nexdevit/nexpdf-electron');
app.whenReady().then(async () => {
const pdf = await openPdfWindow({
file: '/path/to/contract.pdf',
license: '/path/to/nexpdf_license.xml',
});
// Later: await pdf.save('/path/to/out.pdf');
});
app.on('window-all-closed', () => app.quit());Requirements
| Electron | 28 or later (a peer dependency) |
| Node.js | 18 or later |
| Operating systems | Linux (x64, arm64), macOS (universal), Windows (x64) |
| Engine | The nexpdf-webviewer binary for each platform you ship |
How it works
openPdfWindow()starts the engine (nexpdf-webviewer) bound to127.0.0.1on a free port, then opens aBrowserWindowon it. Nothing leaves the machine: the engine only accepts loopback connections.- The window runs with
contextIsolation,sandboxand no Node integration. It cannot navigate away from the engine, and other links open in the user's browser. - It installs a File menu with Open… (
CmdOrCtrl+O) and Save As… (CmdOrCtrl+Shift+S). Downloads from the toolbar ask where to save, like a native app. - Closing the window, or quitting the app, stops the engine.
startEngine(),openDocument()anddocumentBytes()drive the engine without a window.
The document API
documents() and openDocumentFile() (1.1) give the main process the document API of the
Node.js SDK: open, render, read, search, annotate, fill, sign and save documents in
code, with no window and no helper process. It runs NexPDF compiled to WebAssembly in your process,
and doc.raw has every function of the C SDK.
const { openDocumentFile } = require('@nexdevit/nexpdf-electron');
const doc = await openDocumentFile('/path/to/invoice.pdf');
const tables = JSON.parse(doc.raw.extractTablesJson(-1, null)).tables;
await doc.save('/path/to/out.pdf');
doc.close();It needs @nexdevit/nexpdf-node installed and a license key for platform web; see
Opening and saving.
Getting started
Installation
Add the package and ship the engine binary.
Your first window
Open a PDF in a window and save the result.
Add your license key
Activate your key for the engine.
Running without a key
View-only mode, the watermark and trial keys.
Viewer
Window options, the engine and the UI configuration.
Guides
Opening and saving
Open files and bytes, passwords, other formats, save the result.
Viewing pages
Layout, zoom, night reading and panels.
Document structure
Properties, bookmarks, page labels, layers, attachments.
Text and the assistant
Select, copy, ask questions, export the text.
Search
Find text in the document.
OCR
Make scanned pages searchable.
Structured extraction
Extract to JSON in the window; tables, key-values and classification in code.
Barcodes
Read QR, Data Matrix, PDF417 and linear codes; draw barcodes.
Annotations
Markup, shapes, ink, stamps and measurements.
Forms
Fill forms and add fields.
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
Sync pages, annotations, comments, form values and bookmarks.
Editing
Edit page text and organise pages.
Compare and optimise
Compare versions, shrink files, Fast Web View.
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, drawn signatures, verification.
Long-term signatures
Signature levels, document timestamps, B-LTA verification.
Conversion
Open Office files, export to Office, HTML and more.
Templates
PDFs from Word, HTML and PDF templates and JSON data.
PDF/A 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.