Runnable JavaScript examples for IronPDF for Node.js, a PDF library that converts HTML to PDF with a real Chromium renderer and generates, edits, and extracts PDF content.
npm install @ironsoftware/ironpdfimport { PdfDocument, IronPdfGlobalConfig } from "@ironsoftware/ironpdf";
IronPdfGlobalConfig.setConfig({ licenseKey: "YOUR-LICENSE-KEY" });
const pdf = await PdfDocument.fromHtml("<h1>Hello, PDF!</h1>");
await pdf.saveAs("hello.pdf");PdfDocument.fromHtml also accepts a path to an HTML file. To render other sources, use PdfDocument.fromUrl(url) or PdfDocument.fromImage(paths), and PdfDocument.open(path) to load an existing document.
Render settings go under a renderOptions key — fromHtml(html, { renderOptions: { paperSize, margin, paperOrientation } }). Settings passed at the top level are silently ignored, so a page that looks unstyled is usually a misplaced option rather than a failed render.
Without a license key, generated PDFs include a watermark.
Each folder contains a self-contained npm project. Run npm install, then node src/program.js:
examples/— focused snippets demonstrating individual featuresget-started/— first projects covering license keys and remoteIronPdfEnginehow-to/— task-oriented guides for specific PDF operationsquickstart/— an end-to-end project scaffoldtutorials/— a longer HTML-to-PDF walkthrough
- HTML string, HTML file, URL, and image to PDF conversion
- Merging, splitting, and removing pages from existing PDFs
- Headers, footers, page numbers, page breaks, backgrounds, and foregrounds
- Digital signatures, encryption, decryption, and permissions
- Text and image extraction from existing documents
- Rasterizing pages to images, grayscale conversion, and compression
- PDF/A and PDF/UA output
- Custom paper sizes, page orientation, and margins
- Rendering Angular output, embedded Base64 images, barcodes, Google Fonts, and JavaScript charts
- Printing, and running against a remote
IronPdfEngine
Node.js 12.13 and above, with TypeScript type definitions included. Windows, macOS, Linux, Docker, Azure, and AWS. Every project here is ESM — package.json sets "type": "module" — so the examples use import, not require. See the documentation for environment-specific notes.
- Full documentation: ironpdf.com/nodejs/docs
- API reference: ironpdf.com/nodejs/object-reference/api
- npm package: @ironsoftware/ironpdf
- Issues with these examples: file directly on this repository
- Product support: support@ironsoftware.com
This repository is maintained by Iron Software. IronPDF for Node.js is a commercial library — see licensing for terms and trial details.