Skip to content

Instantly share code, notes, and snippets.

@oc
Created October 21, 2009 09:58
Show Gist options
  • Save oc/215002 to your computer and use it in GitHub Desktop.
Save oc/215002 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'barby'
require 'prawn'
require 'barby/outputter/prawn_outputter'
require 'fastercsv'
LEN = 30
def add_data(pdf, id, name, email)
pdf.text "Hurtigregistrering", :size => 20, :at => [0, 300]
pdf.text "Smidig 2009", :size => 20, :at => [0, 270]
pdf.text name, :size => 14, :at => [0, 230]
pdf.text email, :size => 14, :at => [0, 210]
pdf.text id, :size => 20, :at => [0, 135]
pdf.bounding_box [60, 100] do
barcode = Barby::Code128B.new(id)
barcode.annotate_pdf(pdf, { :height => 70, :xdim => 1.3 })
end
pdf.text "Ta denne med på Smidig 2009 for raskere registrering!", :size => 10, :at => [0, 50]
end
def make_ticket(id, name, email)
pdf = Prawn::Document.new(:page_size => "A6")
add_data(pdf, id.to_s, name.strip, email.strip)
File.open("tickets/#{id}.pdf", "w") { |f| f.write(pdf.render) }
end
#Test
#make_ticket(123, "123456789abcdefghijklmnopqrstu", " [email protected]")
FasterCSV.foreach('registrations.csv') do |row|
id,name,email,complete,dinner = row.join.split(';')
make_ticket(id, name, email)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment