Browse Source

baby steps

master
Brennen Bearnes 12 years ago
parent
commit
4c79f30d82
2 changed files with 28 additions and 3 deletions
  1. +28
    -3
      invoice.rb
  2. BIN
      logo.png

+ 28
- 3
invoice.rb View File

@ -1,7 +1,32 @@
#!/usr/bin/env ruby
# try to make a sparkfun invoice using prawn
require 'rubygems'
require 'json'
require 'prawn'
pdf = Prawn::Document.new
pdf.text("sparkfun invoice motherfuckers")
pdf.render_file('testinvoice.pdf')
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)

BIN
logo.png View File

Before After
Width: 188  |  Height: 105  |  Size: 1.9 KiB

Loading…
Cancel
Save