SupeRails
Vložit
- čas přidán 8. 05. 2024
- Thanks to URLBOX for sponsoring today's video! Convert URL to PNG/PDF with UrlBox: urlbox.com/screenshot-api?ref=sr Urlbox also helps to block Ads & Popups, Bypass Captchas, Auto-Accept Cookies
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!
Episode source code: github.com/corsego/158-gem-fe...
Based on this blogpost: blog.corsego.com/gem-ferrum-g...
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
This does look really interesting. I am a bit concerned with the timeouts but I think I may give it a shot creating them in background jobs. I'm currently using PDFShift, which so far is working well, but it would be nice to do it all in house.
I agree: I think it’s best to use background jobs to store generated files (rather than display them in browser on render without saving)
Any pointers on how to deploy it?
here's how: blog.corsego.com/gem-ferrum-generate-pdf#7-heroku
Thanks, @@SupeRails !