This gem provides model responsible for generating pdf from html file.
Add to Gemfile:
gem 'spree_invoice_generator', :git => 'git://github.com/petergebala/spree-invoice-generator.git'
then run:
bundle
Execute:
rails g spree_invoice_generator:install
In file config/initializers/spree_invoice_generator.rb please check your configuration for wkhtmltopdf bin path.
For more see: wicked_pdf
In any model you can generate pdf string:
Spree::InvoicePrint.find_by_order_id('some id').try(:generate_pdf)
or:
Spree::Order.last.invoice_print.generate_pdf
or:
pdfs = []
Spree::User.last.invoice_prints.each { |e| pdfs << e.generate_pdf }
You can also check how many times invoice was generated - column: counter
Before use it please customize your invoice template.
- write missing tests
- clean up model invoice_print
- add counter increase after generating pdf from controller
- create default invoice template
- checkout todos in code
- write better documentation