One way is to serve the data as a webpage. Then with a headless web browser[0] you can visit that web page and "print" the page to a pdf. You can then either save the pdf for download later, or stream it to the user right away. -- Edit: There are also some SaaS products[1] that do this via an API call. -- Edit 2: As others below have pointed out, there are some direct-to-PDF libraries. This is a lighter weight solution (re: compute) than using a headless browser, but more work. It's relatively easy to work on layouts and styles written in HTML+CSS. Using a direct to PDF library would likely require becoming proficient in the library's layout DSL/API. That DSL/API will either have a strict subset of the layout and styling capabilities of HTML+CSS, or it will be roughly as complicated as learning a new HTML+CSS equivalent. -- [0] https://github.com/puppeteer/puppeteer [1] https://www.api2pdf.com Answer from waterstonelakes on reddit.com
🌐
DEV Community
dev.to › handdot › generate-a-pdf-in-js-summary-and-comparison-of-libraries-3k0p
A full comparison of 6 JS libraries for generating PDFs - DEV Community
March 22, 2022 - You can also try Template Design & Code Generator to design your favorite PDF layout and generate some executable code! if you like it, give me a start⭐ https://github.com/pdfme/pdfme ... Puppeteer is by far the easiest for me. You just create a page in your frontend framework with html5 /css and use puppeteer with headless chrome to create en exact pdf of that page. Very easy to do you could create a firebase app to use as backend ... Specialize in HTML, JS, React, Node.js, PDF, etc.
🌐
npm
npmjs.com › package › pdfkit
pdfkit - npm
2 weeks ago - A PDF generation library for Node.js. Latest version: 0.19.1, last published: 8 days ago. Start using pdfkit in your project by running `npm i pdfkit`. There are 1141 other projects in the npm registry using pdfkit.
      » npm install pdfkit
    
Published   Jun 10, 2026
Version   0.19.1
Discussions

Best approach to generate PDF from dynamic data?
One way is to serve the data as a webpage. Then with a headless web browser[0] you can visit that web page and "print" the page to a pdf. You can then either save the pdf for download later, or stream it to the user right away. -- Edit: There are also some SaaS products[1] that do this via an API call. -- Edit 2: As others below have pointed out, there are some direct-to-PDF libraries. This is a lighter weight solution (re: compute) than using a headless browser, but more work. It's relatively easy to work on layouts and styles written in HTML+CSS. Using a direct to PDF library would likely require becoming proficient in the library's layout DSL/API. That DSL/API will either have a strict subset of the layout and styling capabilities of HTML+CSS, or it will be roughly as complicated as learning a new HTML+CSS equivalent. -- [0] https://github.com/puppeteer/puppeteer [1] https://www.api2pdf.com More on reddit.com
🌐 r/node
59
54
February 14, 2023
What’s the best package to create a PDF receipt on node?
Nothing can beat https://jsreport.net/ More on reddit.com
🌐 r/node
11
9
February 28, 2022
Best solution for generating pdf documents from templates
We're having the exact same issue. The best solution I have is to run Puppeteer in a GCP Cloud Function. If it's a warm start, it only takes around 5 seconds for a 1 page PDF. More on reddit.com
🌐 r/node
87
44
March 27, 2023
Is node the right choice for HTML to PDF conversion?
Why bother with converting HTML to PDF? Why not just directly build a PDF with jsPDF or some other library? You said yourself it's a simple header, table, and footer.. that should be pretty simple to make. More on reddit.com
🌐 r/node
54
41
January 13, 2023
People also ask

How do I install a PDF library for Node.js?
To install IronPDF for Node.js, execute `npm i @ironsoftware/ironpdf` in your terminal to get the core library. Then, install the necessary engine with `npm install @ironsoftware/ironpdf-engine-windows-x64` for Windows systems.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › using ironpdf for node.js › flatten pdf python
Node.js PDF Generator (Developer Tutorial) | IronPDF
Is it possible to generate PDFs from web page URLs in Node.js?
Yes, using IronPDF, you can generate PDFs from web page URLs with the PdfDocument.fromUrl method. Provide the URL of the web page you wish to convert, and then use the saveAs method to save your PDF.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › using ironpdf for node.js › flatten pdf python
Node.js PDF Generator (Developer Tutorial) | IronPDF
What are the benefits of using a PDF library in Node.js applications?
Using IronPDF in Node.js applications enhances document handling by allowing the generation of PDFs from various content types, supporting dynamic content, and providing easy integration with JavaScript libraries.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › using ironpdf for node.js › flatten pdf python
Node.js PDF Generator (Developer Tutorial) | IronPDF
🌐
Nutrient
nutrient.io › blog › sdk › top js pdf libraries
Top JavaScript PDF generator libraries for 2026 - Nutrient iOS
February 25, 2026 - Nutrient Node.js SDK — Advanced server-side PDF creation, manipulation, and optimization for Node.js apps. Nutrient .NET SDK — PDF generation and processing in .NET desktop or server environments.
🌐
Reddit
reddit.com › r/node › best approach to generate pdf from dynamic data?
r/node on Reddit: Best approach to generate PDF from dynamic data?
February 14, 2023 -

Hey everyone, currently in my app I have to generate a PDF report of the items bought by a given user, but I have no idea how to do that.

I have created some static PDF (or replacing a few values), but I have no clue on how to implement it with dynamic data, where the PDF could have 1 or dozens of pages.

Do you guys know of any library / approach / tutorial that would help me achieve that?

Thanks in advance!

Top answer
1 of 29
38
All the solution mentioned here are based on some html to pdf conversion, which involves running a browser on your server if you want to do the render serverside. This might be fine at first, but running a web browser along your server can hog a lot of ressources. If this is a concern for you, I suggest you look at projects like pdfkit , they allow you to compose the content of the pdf directly, without using another format (html) has an intermediate layer. The learning curve might be steeper, but you reduce the size of your project (you don't have to bundle a web browser with your app), reduce the ressources used, and have faster render time.
2 of 29
35
One way is to serve the data as a webpage. Then with a headless web browser[0] you can visit that web page and "print" the page to a pdf. You can then either save the pdf for download later, or stream it to the user right away. -- Edit: There are also some SaaS products[1] that do this via an API call. -- Edit 2: As others below have pointed out, there are some direct-to-PDF libraries. This is a lighter weight solution (re: compute) than using a headless browser, but more work. It's relatively easy to work on layouts and styles written in HTML+CSS. Using a direct to PDF library would likely require becoming proficient in the library's layout DSL/API. That DSL/API will either have a strict subset of the layout and styling capabilities of HTML+CSS, or it will be roughly as complicated as learning a new HTML+CSS equivalent. -- [0] https://github.com/puppeteer/puppeteer [1] https://www.api2pdf.com
🌐
pdf noodle
pdfnoodle.com › home › blog › popular libraries 2025 for pdf generation using node js
Popular Libraries 2025 for PDF Generation Using Node JS - pdf noodle
January 15, 2025 - If you don't want to waste time maintaining pdfs layouts and their infrastructure or if you don't want to keep track of best practices to generate PDFs at scale, third-party PDF APIs like pdf noodle will save you hours of work and deliver a ...
🌐
LogRocket
blog.logrocket.com › home › best html to pdf libraries for node.js
Best HTML to PDF libraries for Node.js - LogRocket Blog
November 14, 2024 - Choosing a conversion library for your Node.js project can be a bit daunting, but there are several great options available. If you want to generate PDF from scratch, PDFKit or pdfmake may be the best option. To quickly convert HTML or SVG content ...
Find elsewhere
🌐
Medium
medium.com › deno-the-complete-reference › 5-useful-npm-packages-for-pdf-processing-in-node-js-c573cee51804
5 useful NPM packages for PDF processing in Node.js | Tech Tonic
December 9, 2024 - Developed by the W3C (World Wide Web Consortium), pdf-lib offers a robust set of APIs for working with PDFs in Node.js applications. pdf-lib provides an extensive feature set that enables developers to create, modify, and manipulate PDF documents with ease. Some of its key features include: PDF parsing: pdf-lib allows developers to parse existing PDF files and extract their contents, including text, images, and layout information. PDF generation: The library provides a flexible API for creating new PDF documents from scratch, including support for layout, fonts, and encryption.
🌐
PDFKit
pdfkit.org
PDFKit
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy. The API embraces chainability, and includes both low level functions as well as abstractions for higher level functionality.
🌐
Nutrient
nutrient.io › blog › sdk › how to generate pdf from html with nodejs
Node.js PDF generator: How to generate PDFs from HTML with Node.js
June 24, 2025 - This guide walks through the most effective Node.js PDF generation libraries, including Puppeteer, PDFKit, jsPDF, PDFMake, and Nutrient Document Engine. You’ll learn which ones are best for HTML rendering, layout precision, data-driven content, ...
🌐
IronPDF
ironpdf.com › ironpdf blog › using ironpdf for node.js › flatten pdf python
Node.js PDF Generator (Developer Tutorial) | IronPDF
From simple text-based documents to complex reports with dynamic content, IronPDF simplifies the process and enhances the capabilities of your Node.js applications. Whether you're converting HTML to PDF, populating templates, or compiling images into a PDF file, IronPDF provides a versatile and efficient solution for your PDF generation needs.
Published   April 22, 2026
🌐
Apryse
apryse.com › blog › how-to-generate-dynamic-pdf-documents-nodejs
How to Generate Dynamic PDFs in Node.js | Apryse
Apryse SDK provides the best rendering quality for PDFs, and the most granular control over layout. Apryse SDK provides the most stable, scalable and low-maintenance solution. Finally, it’s extensible for advanced features such as digital ...
Published   February 4, 2026
🌐
DEV Community
dev.to › xeshan6981 › the-5-nodejs-pdf-libraries-every-developer-must-know-4b39
The 5 Node.js PDF Libraries Every Developer Must Know - DEV Community
January 1, 2026 - The libraries discussed—PDFKit, Puppeteer, jsPDF, jsreport, and IronPDF—each offer unique features and capabilities that cater to different use cases. Here are some key criteria to help you determine the best PDF library for your needs: ...
🌐
PDFBolt
pdfbolt.com › blog › top-nodejs-pdf-generation-libraries
Top Node.js HTML to PDF Libraries Compared | PDFBolt
March 17, 2025 - Full tutorial: Generate PDF Using PDFMake in Node.js. PDFKit uses a canvas-like API to build PDFs from scratch instead of converting HTML. You position every element manually, which gives you full control over the layout.
🌐
DEV Community
dev.to › logrocket › best-html-to-pdf-libraries-for-nodejs-17f7
Best HTML to PDF libraries for Node.js - DEV Community
October 24, 2023 - Choosing a conversion library for your Node.js project can be a bit daunting, but there are several great options available. If you want to generate PDF from scratch, PDFKit may be the best option. To quickly convert HTML or SVG content to PDFs, jsPDF may be more suitable.
🌐
DocRaptor
docraptor.com › node-html-to-pdf
Compare Top Node.js HTML to PDF Libraries - Open-Source and Commercial
We use the industry-leading, commercial Prince engine to generate the PDFs. In our opinion, DocRaptor provides the best combination of advanced HTML and JavaScript support along with PDF-specific functionality that dramatically eases development. With simple HTML and CSS, DocRaptor lets you create: ... You can be making advanced PDFs in minutes with DocRaptor's Node.js HTML to PDF code samples and JavaScript HTML to PDF library.
🌐
npm
npmjs.com › package › pdf-creator-node
pdf-creator-node - npm
April 3, 2026 - PhantomJS / html-pdf are no longer used as of v4. Requirements: Node.js 18 or newer. Install size: puppeteer downloads a compatible Chromium build on npm install (hundreds of MB). In CI you can cache the browser directory or set PUPPETEER_CACHE_DIR / PUPPETEER_SKIP_DOWNLOAD as needed. Practical verdict: strong fit for small and medium projects and production workloads where you control memory and concurrency; for very large scale (always-on millions of PDFs/day), plan infrastructure (pooling, autoscaling, or a dedicated rendering service) like any Chromium-based pipeline.
      » npm install pdf-creator-node
    
Published   Apr 03, 2026
Version   4.0.1
🌐
IronPDF
ironpdf.com › nodejs
The Node.js PDF Library (w/ Pixel-Perfect Formatting) | IronPDF for Node.js
IronPDF is the leading Node.js PDF library for generating & editing PDFs.
🌐
Slashdot
slashdot.org › software › document management › pdf generators › node.js
Top PDF Generators for Node.js in 2026
Find the top PDF Generators for Node.js in 2026 for your company. Compare the best PDF Generators for Node.js, read reviews, and learn about pricing and free demos.
🌐
npm
npmjs.com › search
pdf generator - npm search
HTML to PDF Generator for nodejs using puppeteer · puppeteer pdf · html2pdf · html to pdf · typescript · cheerio · html to pdf node js · node js html to pdf library · node js html to pdf converter · how to convert html to pdf in node ...