class Barby::Pdf417
Constants
- DEFAULT_OPTIONS
Public Class Methods
new(data, options={})
click to toggle source
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 26 def initialize(data, options={}) if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" @pdf417 = Java::Pdf417lib.new else @pdf417 = ::Pdf417::Lib.new end self.data = data DEFAULT_OPTIONS.merge(options).each{|k,v| send("#{k}=", v) } end
Public Instance Methods
aspect_ratio=(aspect_ratio)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 45 def aspect_ratio=(aspect_ratio) @pdf417.setAspectRatio(aspect_ratio) end
code_columns=(code_columns)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 61 def code_columns=(code_columns) @pdf417.setCodeColumns(code_columns) end
code_rows=(code_rows)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 57 def code_rows=(code_rows) @pdf417.setCodeRows(code_rows) end
data=(data)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 65 def data=(data) @pdf417.setText(data) end
encoding()
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 69 def encoding @pdf417.paintCode() cols = (@pdf417.getBitColumns() - 1) / 8 + 1 enc = nil # Compute encoding if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" enc = String.from_java_bytes(@pdf417.getOutBits) else enc = @pdf417.getOutBits end enc = enc.bytes.to_a.each_slice(cols).to_a[0..(@pdf417.getCodeRows-1)] return enc.collect do |row_of_bytes| row_of_bytes.collect { |byte| sprintf("%08b", byte) }.join[0..@pdf417.getBitColumns-1] end end
error_level=(error_level)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 49 def error_level=(error_level) @pdf417.setErrorLevel(error_level) end
len_codewords=(len_codewords)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 53 def len_codewords=(len_codewords) @pdf417.setLenCodewords(len_codewords) end
options=(options)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 37 def options=(options) @options = options end
y_height=(y_height)
click to toggle source
# File lib/barby/barcode/pdf_417.rb, line 41 def y_height=(y_height) @pdf417.setYHeight(y_height) end