Skip to main content

PDF Receipts Discussion

General • Asked by Chris Oliver
Related episode

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


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

Thanks for the reply, It worked :)


This is a pretty nice way to create PDF receipts . Have you tried using http://wkhtmltopdf.org/ and https://github.com/pdfkit/p...

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 OneMonth.com in Prawn. It was is finicky and time consuming.


Hey Chris,

I'm sure you're aware of livecoding.tv, 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: https://github.com/excid3/r...

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?


Hey,

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


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.