Some test text!

menu

Get started with Node.js

Welcome to PDFTron. PDFTron technology can be integrated with Node.js using various platforms. You can select your desired platform below.

Get started with Node.js on Windows

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

linkPrerequisites

  • Windows (64-bit)
  • Node.js Version: 8, 9, 10, 11, 12
No trial license key required.
The trial of PDFTron SDK works without a license key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
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).

linkInitial setup

Install the npm package:

npm install @pdftron/pdfnet-node

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

linkRun the samples

  1. Open a command line console
  2. Change the directory to the samples folder
  3. Run all samples:
runall.bat

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

cd AddImageTest
node AddImageTest.js

linkIntegrate into your project

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

const { 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:

const { PDFNet } = require('@pdftron/pdfnet-node'); //you may need to set up NODE_PATH environment variable to make this work.

const main = async() => {
  try {
    const doc = await PDFNet.PDFDoc.create();
    let page = await doc.pageCreate();
    doc.pagePushBack(page);
    doc.save('blank.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
  } catch (err) {
    console.log(err);
  }
};

PDFNet.runWithCleanup(main, 0).then(function(){PDFNet.shutdown();});

linkNext step

GuidesAPI docsSamples

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.