#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
1
Destacado en listas
![#160 Meta Tags. Open Graph, SEO, social sharing previews](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjAzMywicHVyIjoiYmxvYl9pZCJ9fQ==--a75e679f17278e3867a3014fd11c1d6b28101605/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#162 Gem Ferrum - Generate PDF and PNG with Headless Chrome API. No Puppeteer, no NodeJS](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjAzNywicHVyIjoiYmxvYl9pZCJ9fQ==--925c37e549cb1e042defe2ed910ff28fa9e7b79f/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#182 Build an OpenGraph image generator](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjMxOCwicHVyIjoiYmxvYl9pZCJ9fQ==--648608b84d84a175841b4e2cf73fdf3dde5f8051/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--34e5c9bac0ea93c87a890e274478a7e6bd659b29/182.png)
Automate your open-graph social images with screenshots!
Get better CTR to your link with engaging OG social images.
Build a micro SaaS like https://image.social/ or https://tinyzap.co/