Skip to main content

Node.js Client Library


The DynamicPDF API provides a full‑featured client library for Node.js that simplifies integration with the REST endpoints.
The Node.js client library is the official SDK for integrating the DynamicPDF API into Node.js applications and server-side workflows. It provides familiar JavaScript classes and async methods that enable developers to generate PDFs, convert HTML and images to PDF, merge documents, extract text and metadata, and perform detailed PDF inspection while working naturally with Promises and the standard Node.js event loop rather than crafting raw HTTP calls.

By using this library, Node.js developers gain full access to the capabilities of the DynamicPDF API, including creating PDF documents from code, merging or splitting existing PDFs, filling and flattening form fields, stamping text or images, retrieving XMP and document information, rasterizing pages, and applying encryption or other security features. The DynamicPDF API offers a comprehensive set of PDF focused endpoints that support generation, conversion, manipulation, analysis, and secure delivery of PDF content within modern JavaScript and TypeScript applications running on Node.js.

The DynamicPDF API offers clean, intuitive wrappers around the following REST endpoints:

  • dlex-layout for creating dynamic PDF reports from DLEX templates and JSON data,
  • image-info for extracting detailed metadata from images,
  • pdf for creating and manipulating PDFs, merging documents, and converting HTML, Word, and Excel files to PDF,
  • pdf-info for retrieving document information and metadata from existing PDFs,
  • pdf-security-info for obtaining PDF encryption details and security settings,
  • pdf-text for extracting text content from PDF pages, and
  • pdf-xmp for reading embedded XMP metadata from PDF files.

Installation

npm install @dynamicpdf/api

Usage Example

static async Convert(){
var pdf = new Pdf();
pdf.apiKey = Constants.ApiKey;
var resource = new ExcelResource("sample.xlsx", "sample.xlsx")
pdf.addExcel(resource, PageSize.Letter, Orientation.PORTRAIT, 1.0);
var res = await pdf.process();
var outStream = fs.createWriteStream("output.pdf");
outStream.write(res.content);
outStream.close();
}
Source: ExcelWordExample.js