License
Activate a NexPDF license key for the Electron engine, choose its app id, and see which modules it unlocks.
The license is activated by the engine (nexpdf-webviewer) when it starts. Pass it to
openPdfWindow or startEngine as the license option. See Licensing for
how keys are issued and bound.
Activate
const { app } = require('electron');
const path = require('node:path');
const { openPdfWindow } = require('@nexdevit/nexpdf-electron');
app.whenReady().then(() =>
openPdfWindow({
license: path.join(process.resourcesPath, 'nexpdf_license.xml'), // or the bare NEX2. key
}),
);license | Meaning |
|---|---|
| A path to a file | The license XML file, read by the engine |
| Any other string | The bare key |
The engine checks keys for platform server and the app id nexpdf-webviewer. To use your own app
id, set NEXPDF_APP_ID in the engine's environment:
const engine = await startEngine({ license, env: { NEXPDF_APP_ID: 'com.acme.docs' } });Check the status
The window shows the license in its interface (the license toolbar item). The engine also prints
the status JSON, or the reason a key was rejected, on its standard error when it starts.
The status has state (unlicensed, trial, licensed), licensee, id, tier, modules,
expires_at, days_left and watermark.
The document API
The document API
(documents(), 1.1 and later) runs the WebAssembly engine of the Node.js SDK in the main process,
which checks its own key: one issued for platform web, with your app id as the host. It does not
use the engine's server key. Activate it once at start-up:
const fs = require('node:fs');
const path = require('node:path');
const { documents } = require('@nexdevit/nexpdf-electron');
const nex = documents();
nex.activateLicense(fs.readFileSync(path.join(process.resourcesPath, 'nexpdf_web_license.xml'), 'utf8'), 'com.acme.docs');
console.log(nex.licenseStatus()); // { state, licensee, tier, modules, days_left, watermark }activateLicense(keyOrXml, appId) returns 2 (licensed) or 1 (trial) and throws with the reason
when it rejects a key. See Node.js License.
Without a license
Without a key, or after a rejected key, the engine runs view-only: the window opens, renders, searches and shows text, and pages carry the "NexPDF • Unlicensed" watermark. Each mode of the window needs the license module of its feature; see the guides.
Ship the key with your app only as you would any other secret: anyone with the installed app can read a file in its resources.