#155
Vložit
- čas přidán 8. 05. 2024
- 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: github.com/corsego/155-docrap...
Based on this blogpost: blog.corsego.com/docraptor-ht...
Podcast talking about Docraptor: www.indierails.com/15
Docraptor gem: github.com/DocRaptor/docrapto...
Docraptor ruby docs: docraptor.com/documentation/ruby
DocRaptor: 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
i would like to see something different, for put an example, what is the way of using concerns, transaction, active record callback what is the best way to use them, reusables component, reusable modal with stimulus
Hi Yaroslav. Thank you for all the great work you do. Based on the fact that you recommended a paid option that uses an API, does this mean that we should not search for free alternatives?
Hello! There are many different options for rendering PDFs, for example
- weasyprint.org/ (python HTML to PDF)
- github.com/Studiosity/grover (headless browser)
- github.com/rubycdp/ferrum/ (headless browser)
- github.com/prawnpdf/prawn (ruby dsl)
You are absolutely free to use any too that best suits your situation :)
@@SupeRails Thanks. I will look at theses. But for a project i am working on now, i will actually try DocRaptor. After watching your video, it seems easy to use. Thanks again.
@@SupeRails - thanks for video. Did you try Grover? thats the main option I am considering. Prawn is a lot of hard work & in the past I always used wkhtmltopdf.