Class: DynamicPDFApi::TextElement
- Defined in:
- lib/ruby_client/Elements/TextElement.rb
Overview
Represents a text element.
This class can be used to place text on a page.
Instance Attribute Summary collapse
-
#color ⇒ Object
Gets or sets the Color object to use for the text of the text element.
-
#font_size ⇒ Object
Gets or sets the font size for the text of the text element.
-
#text ⇒ Object
Gets or sets the text to display in the text element.
Attributes inherited from Element
#_input_value, #_resource, #_text_font, #_type, #even_pages, #odd_pages, #placement, #x_offset, #y_offset
Instance Method Summary collapse
-
#font(value) ⇒ Object
Gets or sets the Font object used to specify the font of the text for the text element.
-
#initialize(value, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ TextElement
constructor
Initializes a new instance of the TextElement class.
- #to_json(_options = {}) ⇒ Object
Constructor Details
#initialize(value, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ TextElement
Initializes a new instance of the TextElement class.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 19 def initialize(value, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) @_resource = nil @_text_font = nil @_font_name = nil @color = nil @font_size = nil @_type = ElementType::TEXT super(value, placement, x_offset, y_offset) @text = value end |
Instance Attribute Details
#color ⇒ Object
Gets or sets the Color object to use for the text of the text element.
34 35 36 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 34 def color @color end |
#font_size ⇒ Object
Gets or sets the font size for the text of the text element.
39 40 41 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 39 def font_size @font_size end |
#text ⇒ Object
Gets or sets the text to display in the text element.
44 45 46 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 44 def text @text end |
Instance Method Details
#font(value) ⇒ Object
Gets or sets the Font object used to specify the font of the text for the text element.
49 50 51 52 53 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 49 def font(value) @_text_font = value @_font_name = @_text_font._name @_resource = @_text_font._resource end |
#to_json(_options = {}) ⇒ Object
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 |
# File 'lib/ruby_client/Elements/TextElement.rb', line 55 def to_json( = {}) json_array = {} json_array["type"] = "text" json_array["font"] = @_font_name unless @_font_name.nil? json_array["text"] = @text json_array["color"] = @color._color_string if !@color.nil? && !@color._color_string.nil? json_array["fontSize"] = @font_size unless @font_size.nil? # --------------------------------- 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 |