NOW AVAILABLE: Summer 2025 Release
By | 2025 Jul 30
4 min
Tags
docx to pdf
Summary: Convert DOCX files to PDF using Apryse’s Server SDK in Node.js without third-party dependencies. This guide walks through setup, licensing, and sample execution.
Applications with DOCX to PDF conversion for documents like invoices are in high demand. With the Apryse Server SDK for Node.js, developers can develop an app with this feature to convert DOCX files like templates, no matter the size, with the help of Node.js, without any external third party dependencies.
To convert documents from PDF to DOCX in Node.js, we’ll use our Server SDK. We can try it using a trial key. Your trial includes unlimited trial usage and support from solution engineers.
Install the npm package:
Please note that all Apryse NodeJS libraries install native binaries and installing the package will install a system specific distribution.
npm i @pdftron/pdfnet-node
The samples are not included with the pdfnet-node package, and need to be downloaded separately.
Step 1 - Download the samples
Open a command line console, and run:
npm i @pdftron/pdfnet-node-samples
Step 2 - Navigate to the folder where the samples are located
Change the directory to the node_modules/@pdftron/pdfnet-node-samples folder
Step 3 - Add the license key to the sample
You can get your trial key on our documentation page. Please note that the trial key is uniquely generated and should not be shared publicly (eg. On your public github)
The Apryse SDK requires a license key. Open the file LicenseKey.js, and paste the license key into it.
LicenseKey.js
//"Enter your key here. If you don't have it, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.
const LicenseKey = 'YOUR_PDFTRON_LICENSE_KEY';
if(LicenseKey == 'YOUR_PDFTRON_LICENSE_KEY'){
throw ('Please enter your license key by replacing \'YOUR_PDFTRON_LICENSE_KEY\' that is assigned to the LicenseKey variable in Samples/LicenseKey/LicenseKey.js. If you do not have a license key, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key.');
}
exports.Key = LicenseKey;
Step 4 - Run the samples
While you can run samples individually, you can also run all of them together using a script that is in package.json.
npm run test
If you want to run a sample individually, then navigate to its folder, then use node to run the JavaScript file. For example, here's how to run the AddImageTest sample:
cd ./AddImageTest
node AddImageTest.js
You can now import the Apryse 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.
You can also find these instructions in our documentation for getting started with the Apryse Server SDK for Node.js.
Now that you’re all set with the Server SDK, you can run the below sample to convert your DOCX to PDF with this code:
const { PDFNet } = require('@pdftron/pdfnet-node');
async function main() {
// perform the conversion with no optional parameters
const buf = await PDFNet.Convert.office2PDFBuffer(filename);
// end with a PDFDoc (the conversion destination)
const doc = await PDFNet.PDFDoc.createFromBuffer(buf);
}
PDFNet.runWithCleanup(main, 'demo:1742473730671:615059bf0300000000ea14466d1ccafa8b190b984d1a217f47e5596fe0');
For a full sample on PDF conversion, check out https://docs.apryse.com/core/samples/officetopdftest
In addition to document conversion, the Apryse Server SDK is your solution for providing PDF viewer, annotations, text extraction, search, form filling, and more. Check out our Server SDK information page to learn more. When you’re ready to get started, contact sales.
Tags
docx to pdf
Share this post
PRODUCTS
Platform Integrations
End User Applications
Popular Content