HTML to PDF with Ruby and Puppeteer

Install Puppeteer and Grover

npm i puppeteer
gem install grover

Convert HTML to PDF and save to file

require 'grover'

File.open("html.pdf", "wb") do |f|
  f.write(Grover.new('<html><body><h1>Hello World</h1></body></html>').to_pdf)
end

Find out how to take a retina screenshot with Ruby and Puppeteer.

We created Urlbox to make converting HTML to images easy

Learn more about our website screenshot API.