DEV Community

Generating PDF from HTML with Node.js and Puppeteer

Mate Boer on February 05, 2019

Originally published at blog.risingstack.com on February 5, 2019. In this article I’m going to show how you can generate a PDF document from a hea...
Collapse
 
hmadrigal profile image
hmadrigal • Edited

I would like to suggest an additional option. The library wkhtmltopdf.org can be used, it is open source and based on WebKit which helps you to reduce issues of rendering. Also, it has options for customizing headers and footers thru custom js/HTML. It is available in all. most major OS, the only drawback it is that it is a native binary, implying there will be needed bindings (e.g DLLImports in C#) or calling the executable starting a new process (and specifying processing in the command line)

Collapse
 
caleywoods profile image
Caley Woods

This is what I ended up going with several years ago when there was a request to be able to receive a PDF copy of an invoice that we were already creating with HTML / CSS. Worked well enough.

Collapse
 
nonleaguezone profile image
Nonleaguezone
Collapse
 
kritikgarg profile image
kritikgarg • Edited

👏📄 Great article,Mate! Generating PDFs from HTML using Node.js and Puppeteer seems like a very useful tool for businesses and developers. It's amazing to see how technology has made it so easy to convert HTML to PDF and create professional-looking documents. I appreciate the clear explanations and code samples provided in the article. well done!!💡👍
👀📄Recently, I stumbled upon an article about Generate PDF in Salesforce and it's a great guide for those looking to create PDFs in Salesforce for free! 👍

Collapse
 
richardmtp profile image
Richard MTP

Is this support multiple pages? What will happen in case more than 10000 rows in page?

Collapse
 
bmz1 profile image
Mate Boer
Collapse
 
jpdewa180 profile image
Jpdewa

Make your money more here at site Jpdewa

Collapse
 
create1666 profile image
create1666

Hello

Nice job

Collapse
 
mcshaze profile image
McShaze

Yep, it's true!

Collapse
 
vladwebmakaka profile image
vladislav

if your production node has strict firewall rules - you needs aditional interactions with firewall to download puppeter