Posted: 24-10-2017

The best way to convert html to PDFs and images with Browsershot

The best way to convert html to PDFs and images with Browsershot

From Spatie this nice package to convert html to PDFs and images.

To convert html to a pdf or an image using wkhtmltopdf and wkhtmltoimage tends to be the popular option. Unfortunately those tools contain an outdated browser engine to do their thing, so you can’t use any newish css syntax. A while ago Google added a headless mode to Chrome. They’ve also released a javascript library called Puppeteerthat gives you programmatic and fine grained control over Chrome.

Wouldn’t it be great if we could just use Chrome and Puppeteer to convert html to PDFs and images? Browsershot is package that does exactly that. In this post I’d like to introduce v3 of Browsershot, which was recently released.