SupeRails #162 Gem Ferrum - Generate PDF and PNG with Headless Chrome API. No Puppeteer, no NodeJS

11/03/2024 (about 2 months ago)
·
puppeteer ferrum wickedpdf ulrbox grover html2pdf

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:

  1. open page in new tab in PDF format
  2. save page as PDF
  3. 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


1
Sign in to join the conversation