Class: DynamicPDFApi::DataMatrixBarcodeElement

Inherits:
Dim2BarcodeElement show all
Defined in:
lib/ruby_client/Elements/DataMatrixBarcodeElement.rb

Overview

Represents a Data Matrix barcode element.

With some of the .Net runtime (example: .Net Core 2.0), the ECI values 20, 28, 29 and 30 will give the error ‘No data is available for encoding ’code page number’. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.‘.

Instance Attribute Summary collapse

Attributes inherited from Dim2BarcodeElement

#_value_type

Attributes inherited from BarcodeElement

#_color_name, #value, #x_dimension

Attributes inherited from Element

#_input_value, #_resource, #_text_font, #even_pages, #odd_pages, #placement, #x_offset, #y_offset

Instance Method Summary collapse

Methods inherited from BarcodeElement

#color=

Constructor Details

#initialize(value, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0, symbol_size = DataMatrixSymbolSize::AUTO, encoding_type = DataMatrixEncodingType::AUTO, function_character = DataMatrixFunctionCharacter::NONE) ⇒ DataMatrixBarcodeElement

Initializes a new instance of the DataMatrixBarcodeElement class.

Parameters:

  • value (String)

    |array The value of the barcode either as string or as byte array.

  • placement (String) (defaults to: ElementPlacement::TOP_LEFT)

    The placement of the barcode on the page.

  • x_offset (float) (defaults to: 0)

    The X coordinate of the barcode.

  • y_offset (float) (defaults to: 0)

    The Y coordinate of the barcode.

  • symbol_size (String) (defaults to: DataMatrixSymbolSize::AUTO)

    The symbol size of the barcode.

  • encoding_type (String) (defaults to: DataMatrixEncodingType::AUTO)

    The encoding type of the barcode.

  • function_character (String) (defaults to: DataMatrixFunctionCharacter::NONE)

    The def character of the barcode.



28
29
30
31
32
33
34
35
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 28

def initialize(value, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0, symbol_size = DataMatrixSymbolSize::AUTO, encoding_type = DataMatrixEncodingType::AUTO, function_character = DataMatrixFunctionCharacter::NONE)
  @process_tilde = nil
  @_type = ElementType::DATA_MATRIX_BARCODE
  super(value, placement, x_offset, y_offset)
  @_data_matrix_symbol_size = symbol_size
  @_data_matrix_encoding_type = encoding_type
  @_data_matrix_function_character = function_character
end

Instance Attribute Details

#_data_matrix_encoding_typeObject

Returns the value of attribute _data_matrix_encoding_type.



37
38
39
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 37

def _data_matrix_encoding_type
  @_data_matrix_encoding_type
end

#_data_matrix_function_characterObject

Returns the value of attribute _data_matrix_function_character.



37
38
39
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 37

def _data_matrix_function_character
  @_data_matrix_function_character
end

#_data_matrix_symbol_sizeObject

Returns the value of attribute _data_matrix_symbol_size.



37
38
39
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 37

def _data_matrix_symbol_size
  @_data_matrix_symbol_size
end

#_typeObject

Returns the value of attribute _type.



37
38
39
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 37

def _type
  @_type
end

#process_tildeObject

Gets or sets whether to process tilde character.

Setting true will check for ~ character and processes it for FNC1 or ECI characters. With some of the .Net runtime (example: .Net Core 2.0), the ECI values 20, 28, 29 and 30 will give the error ‘No data is available for encoding ’code page number’. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.‘.



47
48
49
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 47

def process_tilde
  @process_tilde
end

Instance Method Details

#to_json(_options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ruby_client/Elements/DataMatrixBarcodeElement.rb', line 49

def to_json(_options = {})
  json_array = {}

  json_array["type"] = "dataMatrixBarcode"

  json_array["processTilde"] = @process_tilde unless @process_tilde.nil?

  json_array["dataMatrixSymbolSize"] = @_data_matrix_symbol_size unless @_data_matrix_symbol_size.nil?

  json_array["dataMatrixEncodingType"] = @_data_matrix_encoding_type unless @_data_matrix_encoding_type.nil?

  unless @_data_matrix_function_character.nil?
    json_array["dataMatrixFunctionCharacter"] =
      @_data_matrix_function_character
  end

  #--------------Dim2BarcodeElement------------------------------

  json_array["valueType"] = @_value_type unless @_value_type.nil?

  #----------------barcodeElement--------------------------------

  json_array["color"] = @color._color_string if !@color.nil? && !@color._color_string.nil?

  json_array["xDimension"] = @x_dimension unless @x_dimension.nil?

  json_array["value"] = @value unless @value.nil?

  # ------------element---------------------

  json_array["placement"] = @placement unless @placement.nil?

  json_array["xOffset"] = @x_offset unless @x_offset.nil?

  json_array["yOffset"] = @y_offset unless @y_offset.nil?

  json_array["evenPages"] = @even_pages unless @even_pages.nil?

  json_array["oddPages"] = @odd_pages unless @odd_pages.nil?

  JSON.pretty_generate(json_array)
end