Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created June 22, 2009 17:23
Show Gist options
  • Select an option

  • Save aslakhellesoy/134084 to your computer and use it in GitHub Desktop.

Select an option

Save aslakhellesoy/134084 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'barby'
require 'barby/outputter/prawn_outputter'
require 'pdf/writer'
if defined?(JRUBY_VERSION)
require 'barby/barcode/pdf_417'
pdf_417 = Barby::Pdf417.new('Trou de boulette')
Prawn::Document.generate('prawn_pdf_417.pdf') do |pdf| # Unpleasant white lines
pdf_417.annotate_pdf(pdf, {:x => 200, :y => 500, :xdim => 2, :ydim => 6})
end
else
require 'barby/outputter/png_outputter'
qr_code = Barby::QrCode.new('Trou de boulette')
pdf = PDF::Writer.new
qr_code.annotate_pdf(pdf, {:x => 200, :y => 500, :xdim => 8, :ydim => 8})
File.open("pdf_writer_qr_code.pdf", "wb") { |f| f.write pdf.render } # Unpleasant white lines
File.open("qr_code.png", "wb") { |f| f.write qr_code.to_png }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment