IronPDF for Node.js - Create, Edit, and Read PDFs in Node.js Scripts

IronPDF is a PDF library that simplifies the effort needed to create and customize PDF documents programmatically using Node.js.

IronPDF has been developed by Iron Software, a company that maintains a growing suite of powerful, high-performance document processing libraries.

IronPDF is also available for use in .NET (C# and VB.NET), Java PDF Library, and Python PDF Library.

Key Features of IronPDF for Node.js

  1. Generate PDFs from HTML, CSS, JavaScript, images, and other file types.
  2. Add headers, footers, attachments, digital signatures, watermarks, and bookmarks to PDF documents.
  3. Secure PDFs from unauthorized access with passwords, digital signatures, metadata, and other security settings.
  4. Full multithreading and asynchronous support for optimal performance for mission-critical applications.

IronPDF has over 50 advanced features for PDF creation and editing for creating, formatting, and editing PDF documents.

Getting Started with IronPDF for Node.js

  1. Install Node.js: Download and install the latest version of Node.js from the official Node.js website.
  2. Install the @ironpdf package: Use the terminal command below to install IronPDF using NPM:

     npm i @ironsoftware/ironpdf
  3. Install the IronPDF Engine: Install the appropriate binary for your operating system:

    For Windows x64:

    npm install @ironsoftware/ironpdf-engine-windows-x64
    npm install @ironsoftware/ironpdf-engine-windows-x64
    SHELL

    For Windows x86:

    npm install @ironsoftware/ironpdf-engine-windows-x86
    npm install @ironsoftware/ironpdf-engine-windows-x86
    SHELL

    For Linux x64:

    npm install @ironsoftware/ironpdf-engine-linux-x64
    npm install @ironsoftware/ironpdf-engine-linux-x64
    SHELL

    For macOS x64:

    npm install @ironsoftware/ironpdf-engine-macos-x64
    npm install @ironsoftware/ironpdf-engine-macos-x64
    SHELL

    For macOS/ARM:

    npm install @ironsoftware/ironpdf-engine-macos-arm64
    npm install @ironsoftware/ironpdf-engine-macos-arm64
    SHELL

    (IronPDF will attempt to download and install the correct binary for your system automatically when your Node.js project runs for the first time. However, in some cases, this action may be blocked by the machine. In such cases, you will need to install the binary using the commands provided above.)

  4. Apply a License Key (optional): In your Node.js project, set the IronPdfGlobalConfig.licenseKey property with a valid license key to use IronPDF:

    // Import the necessary module
    import { IronPdfGlobalConfig } from "@ironsoftware/ironpdf";
    
    (async () => {
       // Create a configuration object with the license key
       const IronPdfConfig = {
           licenseKey: "IRONPDF-MYLICENSE-KEY-1EF01",
       };
    
       // Apply the configuration to the global settings
       IronPdfGlobalConfig.setConfig(IronPdfConfig);
    })();
    // Import the necessary module
    import { IronPdfGlobalConfig } from "@ironsoftware/ironpdf";
    
    (async () => {
       // Create a configuration object with the license key
       const IronPdfConfig = {
           licenseKey: "IRONPDF-MYLICENSE-KEY-1EF01",
       };
    
       // Apply the configuration to the global settings
       IronPdfGlobalConfig.setConfig(IronPdfConfig);
    })();
    JAVASCRIPT

    (If you are getting the following warning, please add the line "type": "module" as a first-level entry in your package.json file. (node:105376) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use node --trace-warnings ... to show where the warning was created))

  5. Enable Debug (optional): In your Node.js project, set the IronPdfGlobalConfig.debugMode property to true to enable debugging. This action will also create a log file in the current directory:

    // Import the necessary module
    import { IronPdfGlobalConfig } from "@ironsoftware/ironpdf";
    
    (async () => {
       // Retrieve the current configuration
       var config = IronPdfGlobalConfig.getConfig();
       // Enable debug mode
       config.debugMode = true;
    })();
    // Import the necessary module
    import { IronPdfGlobalConfig } from "@ironsoftware/ironpdf";
    
    (async () => {
       // Retrieve the current configuration
       var config = IronPdfGlobalConfig.getConfig();
       // Enable debug mode
       config.debugMode = true;
    })();
    JAVASCRIPT

Using IronPDF for Node.js

Convert HTML to PDF

Use PdfDocument.fromHtml to convert raw HTML into PDFs. This method can work with a string containing HTML or a file path to an HTML document.

// Import the needed module
import { PdfDocument } from "@ironsoftware/ironpdf";

/* Convert an HTML String to a PDF */
PdfDocument.fromHtml("<h1>Hello world!</h1><p><small>A PDF brought to you by IronPDF for Node.js!</small></p>")
.then((pdf) => {
    // Save the generated PDF
    pdf.saveAs("./html-string-to-pdf.pdf");
});

/* Convert an HTML File to a PDF */
PdfDocument.fromHtml("./index.html")
.then((pdf) => {
    // Save the generated PDF
    pdf.saveAs("./html-file-to-pdf.pdf");
});
// Import the needed module
import { PdfDocument } from "@ironsoftware/ironpdf";

/* Convert an HTML String to a PDF */
PdfDocument.fromHtml("<h1>Hello world!</h1><p><small>A PDF brought to you by IronPDF for Node.js!</small></p>")
.then((pdf) => {
    // Save the generated PDF
    pdf.saveAs("./html-string-to-pdf.pdf");
});

/* Convert an HTML File to a PDF */
PdfDocument.fromHtml("./index.html")
.then((pdf) => {
    // Save the generated PDF
    pdf.saveAs("./html-file-to-pdf.pdf");
});
JAVASCRIPT

Convert URL to PDF

PdfDocument.fromUrl fetches a web page's content by URL and converts it into a PDF.

// Import the needed module
import { PdfDocument } from "@ironsoftware/ironpdf";

/* Convert a URL to a PDF */
(async () => {
   const pdf = await PdfDocument.fromUrl("https://ironpdf.com/nodejs/");
   // Save the generated PDF
   await pdf.saveAs("./url_to_pdf.pdf");
})();
// Import the needed module
import { PdfDocument } from "@ironsoftware/ironpdf";

/* Convert a URL to a PDF */
(async () => {
   const pdf = await PdfDocument.fromUrl("https://ironpdf.com/nodejs/");
   // Save the generated PDF
   await pdf.saveAs("./url_to_pdf.pdf");
})();
JAVASCRIPT

Licensing & Support Available

Purchase a license key for IronPDF to use IronPDF in production. Alternatively, apply for a free trial license for IronPDF to try IronPDF before you buy it.

For more support and inquiries, please contact our support team.

Darrius Serrant
Full Stack Software Engineer (WebOps)

Darrius Serrant holds a Bachelor’s degree in Computer Science from the University of Miami and works as a Full Stack WebOps Marketing Engineer at Iron Software. Drawn to coding from a young age, he saw computing as both mysterious and accessible, making it the perfect medium for creativity and problem-solving.

At Iron Software, Darrius enjoys creating new things and simplifying complex concepts to make them more understandable. As one of our resident developers, he has also volunteered to teach students, sharing his expertise with the next generation.

For Darrius, his work is fulfilling because it is valued and has a real impact.

Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?