Running without a license key
What the NexPDF window and engine do before a key is activated, how the watermark works, and how to evaluate every module with a trial key.
You do not need a key to install the Electron package, write code against it or run it. When the engine starts without a key, it runs in view-only mode:
- the
viewermodule works: the window opens documents, shows pages, searches, selects and copies text, and shows bookmarks, comments and attachments; - pages carry a "NexPDF • Unlicensed" watermark, and the toolbar shows an "unlicensed" chip;
- every action that needs another module (annotating, filling forms, editing, signing, ...) fails,
and the window shows the engine's message, for example
no license activated: 'annotations' requires a NexPDF license key.
const { app } = require('electron');
const { openPdfWindow } = require('@nexdevit/nexpdf-electron');
app.whenReady().then(async () => {
const pdf = await openPdfWindow({ file: 'contract.pdf' }); // no license option
const bytes = await pdf.bytes(); // works: saving is not gated
});The engine looks for a key in the license option (which sets NEXPDF_LICENSE) and, when there is
none, in a nexpdf_license.xml file in its working folder. With neither, it prints
NexPDF: no license key (set NEXPDF_LICENSE) - running view-only with a watermark on its standard
error.
What works without a key
| Area | In the window | From code |
|---|---|---|
| Opening and saving | Open, Download, File, Open… and Save As… | openPdfWindow, startEngine, pdf.open, openDocument, pdf.save, pdf.bytes, documentBytes |
| Viewing | The View mode, zoom, layout, rotation, night reading, full screen, thumbnails | |
| Text | Search, select and copy, the assistant | |
| Reading structure | Bookmarks, comments, attachments (save a copy) | |
| Comparing | Compare documents in the Convert mode |
In the document API
(documents()), opening, rendering, text, search, reading annotations and word-level comparison work
without a key (verifying signatures needs signatures), as in the
Node.js SDK.
Everything else needs a key that includes the module of the mode: annotations and measurements,
forms, the Edit and Pages modes, the Protect mode, redaction, signing, export to other formats, OCR
and the ISO standards. Showing and hiding layers in the window changes the document and needs the
editor module. Each guide names the module its mode needs.
Check the mode at run time
The engine serves its license status at /api/license. From the main process:
const status = await (await fetch(`${pdf.engine.url}/api/license`)).json();
if (status.state === 'unlicensed') {
console.log('view-only mode, pages are watermarked');
} else if (status.state === 'trial') {
console.log(`trial, ${status.days_left} days left`);
} else {
console.log('licensed for', status.modules.join(', '));
}Use status.modules to leave out of modeConfig.availableModes the modes your key does not unlock;
see Viewer.
Evaluate with a trial key
A trial key unlocks every module so you can try annotations, signing, redaction and the rest. It
keeps a "NexPDF • Trial" watermark on the pages, and the chip shows the days left. Trial keys last 30
days; ask for one from the pricing page and pass it as the license option exactly like
a commercial key; see License.
Do not ship view-only or trial builds
The watermark is drawn on the pixels of rendered pages only; documents you save are not changed. Even so, view-only and trial modes are for development and evaluation. Production apps need a commercial key for the modules they use. See Licensing and the modules per plan.
The license chip
While the engine is unlicensed or on a trial, the toolbar shows a chip that opens a license dialog,
where a user can paste a key. A key pasted there is activated for that engine only, until it stops;
it is not saved. To hide the chip, add license to toolbarConfig.hiddenItems.