Class: DynamicPDFApi::Code128BarcodeElement
- Inherits:
-
TextBarcodeElement
- Object
- Element
- BarcodeElement
- TextBarcodeElement
- DynamicPDFApi::Code128BarcodeElement
- Defined in:
- lib/ruby_client/Elements/Code128BarcodeElement.rb
Overview
Represents a Code 128 barcode element.
This class can be used to place a Code 128 barcode on a page.
Instance Attribute Summary collapse
-
#_type ⇒ Object
Returns the value of attribute _type.
-
#height ⇒ Object
Gets or sets the height of the barcode.
-
#process_tilde ⇒ Object
Gets or Sets a boolean indicating whether to process the tilde character.
-
#ucc_ean128 ⇒ Object
Gets or sets a boolean representing if the barcode is a UCC / EAN Code 128 barcode.
Attributes inherited from TextBarcodeElement
#_font_name, #_resource, #_text_font, #font_size, #show_text, #text_color
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
-
#initialize(value, height, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ Code128BarcodeElement
constructor
Initializes a new instance of the Code128BarcodeElement class.
- #to_json(_options = {}) ⇒ Object
Methods inherited from TextBarcodeElement
Methods inherited from BarcodeElement
Constructor Details
#initialize(value, height, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ Code128BarcodeElement
Initializes a new instance of the Code128BarcodeElement class.
Code sets can be specified along with data, in order to do this ProcessTilde property needs to be set to true. Example value: ‘~BHello ~AWORLD 1~C2345’, where ~A, ~B and ~C representing code sets A, B and C respectively. However if any inline code set has invalid characters it will be shifted to an appropriate code set.
26 27 28 29 30 31 32 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 26 def initialize(value, height, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) @ucc_ean128 = nil @process_tilde = nil @_type = ElementType::CODE128_BARCODE super(value, placement, x_offset, y_offset) @height = height end |
Instance Attribute Details
#_type ⇒ Object
Returns the value of attribute _type.
34 35 36 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 34 def _type @_type end |
#height ⇒ Object
Gets or sets the height of the barcode.
39 40 41 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 39 def height @height end |
#process_tilde ⇒ Object
Gets or Sets a boolean indicating whether to process the tilde character.
If true checks for fnc1 (~1) character in the barcode Value and checks for the inline code sets if present in the data to process. Example value: ‘~BHello ~AWORLD 1~C2345’, where ~A, ~B and ~C representing code sets A, B and C respectively. However if any inline code set has invalid characters it will be shifted to an appropriate code set. ‘' is used as an escape character to add ~.
56 57 58 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 56 def process_tilde @process_tilde end |
#ucc_ean128 ⇒ Object
Gets or sets a boolean representing if the barcode is a UCC / EAN Code 128 barcode.
If true an FNC1 code will be the first character in the barcode.
46 47 48 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 46 def ucc_ean128 @ucc_ean128 end |
Instance Method Details
#to_json(_options = {}) ⇒ Object
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 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruby_client/Elements/Code128BarcodeElement.rb', line 58 def to_json( = {}) json_array = {} json_array["type"] = "code128Barcode" json_array["height"] = @height unless @height.nil? json_array["uccEan128"] = @ucc_ean128 unless @ucc_ean128.nil? json_array["processTilde"] = @process_tilde unless @process_tilde.nil? #----------------TextBarcodeElement--------------------------------- json_array["font"] = @_font_name unless @_font_name.nil? json_array["textColor"] = @text_color._color_string if !@text_color.nil? && !@text_color._color_string.nil? json_array["fontSize"] = @font_size unless @font_size.nil? json_array["showText"] = @show_text unless @show_text.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 |