#162 Gem Ferrum - Generate PDF and PNG with Headless Chrome API. No Puppeteer, no NodeJS
Ferrum is Headless Chrome Ruby API.
Ferrum lets you open a headless chrome browser and perform different actions:
- visit web page
- HTTP authenticate
- find element by css/id
- click link
- fill in input field
- take screenshot of a page
- save page as PDF
In this episode we will:
- open page in new tab in PDF format
- save page as PDF
- save page as PNG
Unlike Grover, it does not require Puppeteer and NodeJS dependencies!
PRO MODE: Convert URL to PNG/PDF with UrlBox: https://urlbox.com/screenshot-api?ref=sr
Urlbox also helps to block Ads & Popups, Bypass Captchas, Auto-Accept Cookies
Episode source code: https://github.com/corsego/158-gem-ferrum/commit/34cd066e06955a84b8326348aa8b99efdbfc7e51
Based on this blogpost: https://blog.corsego.com/gem-ferrum-generate-pdf
0:00 Thanks, URLBOX
2:01 why Ferrum
4:48 URL to PNG
6:10 URL to PDF
7:07 open page as PDF
10:28 CSS for media print
12:10 attach invoice as PDF with ActiveStorage
16:45 attach invoice as PNG
22:11 PendingConnectionsError