Let's solve a classic problem: generate an invoice and email it as PDF to a client.
Historically I would do it with gem wicked_pdf. But the underlying technology wkhtmltopdf is now Archived!
So, we need to find other solutions.
DocRaptor is an affordable API wrapper around the expensive Prince technology, that gives you a lot of options for rendering and storing PDF.
Episode source code: https://github.com/corsego/155-docraptor/commit/0cce2a5367ae4222fc5bd3bc8f70f1a75f75ebe1
Based on this blogpost: https://blog.corsego.com/docraptor-html-to-pdf
Podcast talking about Docraptor: https://www.indierails.com/15
Docraptor gem: https://github.com/DocRaptor/docraptor-ruby
Docraptor ruby docs: https://docraptor.com/documentation/ruby
DocRaptor: https://docraptor.com
P.S. In the episode I forgot to mention another powerful feature that I love: generating a PDF from an URL.
P.S.2. Docraptor pricing is per document, not per page!
0:00 The PDF problem
4:50 Demo of Invoice app
6:15 Generate a PDF with DocRaptor
10:20 Generate an Invoice PDF
13:15 PDF layout file
14:51 Store PDF with ActiveStorage
21:37 Preview, download PDF
27:15 Email the PDF
30:47 DocRaptor document hosting
34:50 Final Demo
37:50 Final thoughts