HTML to PNG with Ruby and Puppeteer
Install Puppeteer and Grover
npm i puppeteer
gem install grover
Convert HTML to PNG and save to file
require 'grover'
File.open("html.png", "wb") do |f|
f.write(Grover.new('<html><body><h1>Hello World</h1></body></html>').to_png)
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.