Class | Barby::Pdf417 |
In: |
lib/barby/barcode/pdf_417.rb
|
Parent: | Barcode2D |
DEFAULT_OPTIONS | = | { :options => 0, :y_height => 3, :aspect_ratio => 0.5, :error_level => 0, :len_codewords => 0, :code_rows => 0, :code_columns => 0 |
Creates a new Pdf417 barcode. The options argument can use the same keys as DEFAULT_OPTIONS. Please consult the source code of Pdf417lib.java for details about values that can be used.
# File lib/barby/barcode/pdf_417.rb, line 22 22: def initialize(data, options={}) 23: @pdf417 = Java::Pdf417lib.new 24: self.data = data 25: DEFAULT_OPTIONS.merge(options).each{|k,v| send("#{k}=", v) } 26: end
# File lib/barby/barcode/pdf_417.rb, line 36 36: def aspect_ratio=(aspect_ratio) 37: @pdf417.setAspectRatio(aspect_ratio) 38: end
# File lib/barby/barcode/pdf_417.rb, line 52 52: def code_columns=(code_columns) 53: @pdf417.setCodeColumns(code_columns) 54: end
# File lib/barby/barcode/pdf_417.rb, line 48 48: def code_rows=(code_rows) 49: @pdf417.setCodeRows(code_rows) 50: end
# File lib/barby/barcode/pdf_417.rb, line 60 60: def encoding 61: @pdf417.paintCode() 62: 63: cols = (@pdf417.getBitColumns() - 1) / 8 + 1 64: enc = [] 65: row = nil 66: @pdf417.getOutBits.each_with_index do |byte, n| 67: if n%cols == 0 68: row = "" 69: enc << row 70: end 71: row << sprintf("%08b", (byte & 0xff) | 0x100) 72: end 73: enc 74: end
# File lib/barby/barcode/pdf_417.rb, line 40 40: def error_level=(error_level) 41: @pdf417.setErrorLevel(error_level) 42: end
# File lib/barby/barcode/pdf_417.rb, line 44 44: def len_codewords=(len_codewords) 45: @pdf417.setLenCodewords(len_codewords) 46: end
# File lib/barby/barcode/pdf_417.rb, line 28 28: def options=(options) 29: @options = options 30: end