Invoicing is crucial part of every application which supports any kind of payments. If you don't need very sophisticated custom solution, available Ruby gems will be perfect option for you.
My assumption is that you have some basic app structure with orders, products and so on.
Invoicing framework gem - https://github.com/code-mancers/invoicing
Prawn - PDF generator https://github.com/prawnpdf/prawn
Support for tables in Prawn https://github.com/prawnpdf/prawn-table
Firstly, we have to do the basic setup of invoicing gem, which can be found here: http://invoicing.codemancers.com/#installation
Codemancers website pretty much explains how to use the invoicing gem, but not everything is covered.
First of all, you’ll be really happy when you install (at least for testing purposes) some kind of admin panel, which will allow you to easily modify values and have a bigger perspective on what is available for you. I chose RailsAdmin for this, as it doesn’t require any additional setup. You can easily remove it later.
Nothing fancy if you want to create it through console:
Create PDF from your invoice:
Alternative solution is using wicked_pdf, which will allow you to render your invoice directly from the controller action (for example in admin panel or wherever you’re going to put the “Generate PDF” button) using HTML/HAML partial.
Personally I prefer to create my own invoice templates, because it gives me an ability to define my own attributes in generated PDF and not rely completely on gem implementation.
You now have working application with basic invoicing system and you’re able to generate PDFs from them. I tried to find some other gems, but it looks like there are no alternative solutions that are worth mentioning. So, note to you, you can always create your own gem with better implementation, but to be honest problem isn’t really that complicated. Most developers just write their own solutions that are easier to customize.