All threads / PDF Receipts Discussion
Ask A Question


You’re not receiving notifications from this thread.

PDF Receipts Discussion

Discussion for PDF Receipts

hashes are ordered too (for the design choice) i think since ruby 1.9 the only real difference is that "keys" can be duplicated in the array style

Ah yeah, you're right. I have always been careful about hashes when it comes to ordering because I wasn't sure it was a requirement for the ruby implementation.

Is it possible to render the pdf without controller? maybe sending out via emails, or saving to s3

Yep, you can call the "render" method like you normally would and send it as an attachment to email or upload it to S3

Anshul Garg ·

Can you give me direction on using "endless scrolling in rails" instead of pagination.
Thanks in advance.

Anshul Garg ·

Thanks for the reply, It worked :)

This is a pretty nice way to create PDF receipts . Have you tried using and

I haven't yet, but really want to. Obviously the HTML to PDF will be way easier than how Prawn does it. The programmatic generation is no fun at all.

I love wkhtmltopdf. It has saved my ass on a bunch of projects in the past. It's become my goto for PDF generation in almost any language I use. Prawn is a pain in the butt, I've used it on two projects and it has been very painful, but you do get a lot of control.

I will check it out! I did some research and can't remember why I picked prawn other than I saw enough other people using it and documentation seemed robust. That said, I bet wkhtmltopdf is way easier now that I've used Prawn more than a little.

The hardest part was building our completion certificates at in Prawn. It was is finicky and time consuming.

Routine Tracker ·

Hey Chris,

I'm sure you're aware of, but I think it would be awesome for you to livestream the creation of gems like this so we can see the process. Plus, then we'd have the recorded streams to go back to and reference.

There aren't very many Rails streams, so it would also be a great opportunity to gain some followers for GoRails!

Hey, the gem it's pretty nice, I'll try with a project that i'm working, but i have a question first, Can I put footer and header to the PDF as Prawn gem?.

It's basically designed to be simpler rather than customizable, but you can take the PDF code that's in the gem and adapt it easily to add your own header and footer. Take a look at this code:

Hi, I'm not familiar with extending a class from a gem. I tried to copy your gem receipt.rb into my models folder, but no change I make to the style in this receipt.rb will have any effect. What do I do wrong?
Thanks a lot

You basically need to just copy paste the module and class into a file in your app (say config/initializers/receipts.rb) and then override the methods you want to change inside the class. You can also copy and paste the entire file there into your app if you want to modify all of it.

How to make a receipt from a form after client clicked submit button?


Do you think it's possible to generate a new receipt everytime the customer get charged?
I assume there's something to do with the transaction logs to automate this?

TY and good job! ;)

Yeah! So normally with subscriptions, I listen to the charge.created webhook and save a copy of it to the database as a Charge record. That's like the example I use. The reason for needing the webhook is that subscriptions charge the user monthly and they don't have to initiate anything in your app.

For one-time charges, you can create a Charge object immediately during checkout and use that.

And if you want to store the receipt PDF files instead of generating them dynamically each time, you can save the file it generates to S3 and save it using Shrine or Carrierwave, etc and just link to that file from your view.

Ok, that's a really smart way to do it!

TY and keep doing GoRails ;)!

I definitely will and thanks for the support! :D

Hello, Great lesson. I am bigger at rails so I want to know to add line_items array in your receipts thanks

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 70,078+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.