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

#!/usr/bin/env ruby
# try to make a sparkfun invoice using prawn
require 'rubygems'
require 'json'
require 'prawn'
class SparkPDF
def spit (structure)
Prawn::Document.generate('testinvoice.pdf', :page_layout => :portrait) do
font "Courier"
text "SparkFun Invoice", :at => [10, 20]
image "logo.png", :width => 84, :height => 52
structure.each do |thing|
text thing
end
number_pages "<page> of <total>", [bounds.right - 50, bounds.top - 10]
end
end
end
# test code
fakeinput = JSON ['bar', 'foo', 'baz']
structure = JSON fakeinput
document = SparkPDF.new
document.spit(structure)