DEV Community

Generate simple PDF from HTML

Chuongtran on October 04, 2018

html_to_pdf Generate simple PDF invoice from HTML using puppeteer & handlebars Introduce Puppeteer Puppeteer is N...
Collapse
 
nickpad profile image
Nick

The data: text/html trick is cool to avoid having to serve the final HTML to Chrome. I guess if images were involved you'd need to start serving the files from somewhere though.

I recently wrote up a bit of an overview of various ways you can use Chrome headless for PDF conversion here.

Collapse
 
chuongtrh profile image
Chuongtran

Thanks for your reply :)

With images, we can convert to base64 and embed to HTML. No need start serving the files from somewhere

Collapse
 
nickpad profile image
Nick

Oh yeah, that's clever too!