Method: Easyzpl::LabelTemplate#variable_bar_code_39

Defined in:
lib/easyzpl/label_template.rb

#variable_bar_code_39(x, y, params = {}) ⇒ Object

Sets a variable bar code that can be recalled



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/easyzpl/label_template.rb', line 82

def variable_bar_code_39(x, y, params = {})
  x = 0 unless numeric?(x)
  y = 0 unless numeric?(y)
  options = { height: 0.1, width: 0.1 }.merge!(params)

  # update the variable field count
  self.variable_fields_count += 1

  label_data.push('^FO' + Integer(x * printer_dpi).to_s + ',' +
                  Integer(y * printer_dpi).to_s)
  label_data.push('^BY2,2,100')

  if params[:orientation] == :landscape
    label_data.push('^B3B,')
  else
    label_data.push('^B3N,')
  end

  label_data.push('Y,' + Integer(options[:height] * printer_dpi).to_s +
                  ',N,N^FN' + variable_fields_count.to_s + '^FS')

  # return unless label_height && label_width
  # options = { height: 20 }.merge(params)
  # draw_bar_code_39('VARIABLEFIELD' + variable_fields_count.to_s,
  #                  Integer(x * pdf_dpi), Integer(y * pdf_dpi),
  #                  Integer(options[:height] * pdf_dpi))
end