Skip to Content
NexPDF

Installation

Add the NexPDF Node.js package and its WebAssembly engine to a Node.js, Deno or Bun project.

English

Get the package

The source of the package is the public repository nexdevit/nexpdf-nodejs:

git clone https://github.com/nexdevit/nexpdf-nodejs

Add the WebAssembly engine

The engine is distributed separately. Download nexpdf-wasm-node-1.1.0.tar.gz from the v1.1.0 release and extract it into the package. It creates the wasm/ folder:

tar -xzf nexpdf-wasm-node-1.1.0.tar.gz -C nexpdf-nodejs
nexpdf.js
nexpdf.d.ts
nexpdf_bg.wasm
package.json
client.mjs
index.mjs
index.d.ts
package.json

Install it in your project

npm install ./nexpdf-nodejs

The package is an ES module, with a CommonJS entry for require as well. It has these entry points:

ImportContents
@nexdevit/nexpdf-nodeThe engine: PdfDocument, WasmDocument, activateLicense, licenseStatus, version, verifySignatures, pkcs12Info, addLtv, detectKind, externalSignatureData, completeExternalSignature, NexPdfClient. With require, the same without NexPdfClient
@nexdevit/nexpdf-node/syncNexPdfSync, the real-time collaboration client (ES module only)
@nexdevit/nexpdf-node/clientNexPdfClient alone, an HTTP client for a NexPDF WebViewer server

Check the installation

node -e "import('@nexdevit/nexpdf-node').then((n) => console.log(n.version()))"

Docker

Dockerfile
FROM node:22-slim
WORKDIR /app
ADD https://github.com/nexdevit/nexpdf-nodejs/archive/refs/tags/v1.1.0.tar.gz /tmp/sdk.tar.gz
ADD https://github.com/nexdevit/nexpdf-nodejs/releases/download/v1.1.0/nexpdf-wasm-node-1.1.0.tar.gz /tmp/wasm.tar.gz
RUN mkdir -p /opt/nexpdf-nodejs \
 && tar -xzf /tmp/sdk.tar.gz -C /opt/nexpdf-nodejs --strip-components=1 \
 && tar -xzf /tmp/wasm.tar.gz -C /opt/nexpdf-nodejs
COPY package*.json ./
RUN npm install /opt/nexpdf-nodejs && npm install
COPY . .
CMD ["node", "server.mjs"]

Serverless

The engine is a single WebAssembly file loaded from wasm/, so it runs on serverless platforms that run Node.js. Make sure your bundler copies wasm/nexpdf_bg.wasm with the function, and activate the license once per cold start, outside the request handler.

HTTP client for a WebViewer server

NexPdfClient talks to a NexPDF WebViewer server instead of running the engine in-process. It sends no authentication, so use it with a server in local mode, on the same machine.

import { readFile, writeFile } from 'node:fs/promises';
import { NexPdfClient } from '@nexdevit/nexpdf-node/client';

const client = new NexPdfClient('http://127.0.0.1:7878');
await client.uploadPdf(await readFile('report.pdf'), 'report.pdf');
await writeFile('report.docx', await client.convertTo('docx'));
await writeFile('page1.png', await client.renderPagePng(0, 150));
MethodRequest
new NexPdfClient(serverUrl?)Default http://127.0.0.1:7878
uploadPdf(buffer, filename?)POST /api/upload; opens the document on the server
fromHtml(html)POST /api/generate/html; creates a PDF from HTML on the server
convertTo(format)GET /api/export/{format}; returns a Buffer
renderPagePng(pageIndex?, dpi?)GET /api/page/{pageIndex}/png; returns a Buffer (defaults 0, 150)

The server's license applies to these calls, not the one activated in your process.

Building the engine yourself

With access to the NexPDF source tree and wasm-pack, run npm run build in sdks/nodejs. It writes wasm/. npm test runs a smoke test; set NEXPDF_LICENSE to run the licensed paths.

On this page