Messing around with Prawn, may use it to generate invoices
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
644 B

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. #!/usr/bin/env ruby
  2. # try to make a sparkfun invoice using prawn
  3. require 'rubygems'
  4. require 'json'
  5. require 'prawn'
  6. class SparkPDF
  7. def spit (structure)
  8. Prawn::Document.generate('testinvoice.pdf', :page_layout => :portrait) do
  9. font "Courier"
  10. text "SparkFun Invoice", :at => [10, 20]
  11. image "logo.png", :width => 84, :height => 52
  12. structure.each do |thing|
  13. text thing
  14. end
  15. number_pages "<page> of <total>", [bounds.right - 50, bounds.top - 10]
  16. end
  17. end
  18. end
  19. # test code
  20. fakeinput = JSON ['bar', 'foo', 'baz']
  21. structure = JSON fakeinput
  22. document = SparkPDF.new
  23. document.spit(structure)