Node.js PDF library integration

Welcome to Apryse. Node.js for the Apryse SDK is supported on Windows, Linux and macOS. To get started, choose your preferred platform from the tabs below.

Windows Node.js PDF library integration

This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into Node.js projects on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

Download the SDK

Download

Prerequisites

  • Windows (64-bit)
  • Node.js Version: 8 - 20

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Keep your commercial license key confidential.

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

Initial setup

  1. Install the npm package:

Please note that all Apryse NodeJS libraries install native binaries and installing the package will install a system specific distribution.

sh

1npm i @pdftron/pdfnet-node
  1. Get your Apryse trial key.

License Key

Apryse collects some data regarding your usage of the SDK for product improvement.

If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.

If your OS or Node.js version is not supported, the installation will fail.

Run the samples

  1. Open a command line console, and run

sh

1npm i @pdftron/pdfnet-node-samples
  1. Change the directory to the node_modules/@pdftron/pdfnet-node-samples folder
  2. Run all samples:

sh

1npm run test

You can also enter any individual sample folder to run them separately. For example, here's how to run the AddImageTest sample:

sh

1cd samples/AddImageTest
2node AddImageTest.js

Integrate into your project

You can now import the Apryse SDK by using the following in your Node.js code:

JavaScript

1const { PDFNet } = require('@pdftron/pdfnet-node');

At the end of your code, don't forget to call PDFNet.shutdown(), otherwise your Node.js program will keep hanging.

Here is an example for creating a blank pdf page:

JavaScript

1const { PDFNet } = require('@pdftron/pdfnet-node'); // you may need to set up NODE_PATH environment variable to make this work.
2
3const main = async () => {
4 const doc = await PDFNet.PDFDoc.create();
5 const page = await doc.pageCreate();
6 doc.pagePushBack(page);
7 doc.save('blank.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
8};
9
10// add your own license key as the second parameter, e.g. in place of 'YOUR_LICENSE_KEY'.
11PDFNet.runWithCleanup(main, 'YOUR_LICENSE_KEY')
12 .catch(function (error) {
13 console.log('Error: ' + JSON.stringify(error));
14 })
15 .then(function () {
16 PDFNet.shutdown();
17 });

Next step

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales