Class: DynamicPDFApi::PageNumberingElement
- Defined in:
- lib/ruby_client/Elements/PageNumberingElement.rb
Overview
Represents a page numbering label page element.
This class can be used to add page numbering to a PDF document. The following tokens can be used within the text of a PageNumberingLabel. They will be replaced with the appropriate value when the PDF is output. table All tokens except the /%/%PR/%/% token can also contain a numbering style specifier. The numbering style specifier is placed in parenthesis after the token. table There should be no spaces within a token, only the token and optional numbering style specifier. This token is invalid /%/%CP ( i )/%/% because of the extra spaces.Here are some examples of valid tokens: margin-top: 0px
Instance Attribute Summary collapse
-
#_font_name ⇒ Object
Returns the value of attribute _font_name.
-
#color ⇒ Object
Gets or sets the Color object to use for the text of the label.
-
#font_size ⇒ Object
Gets or sets the font size for the text of the label.
-
#text ⇒ Object
Gets or sets the text to display in the label.
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 to use for the text of the label.
-
#initialize(text, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ PageNumberingElement
constructor
Initializes a new instance of the PageNumberingElement class.
- #to_json(_options = {}) ⇒ Object
Constructor Details
#initialize(text, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ PageNumberingElement
Initializes a new instance of the PageNumberingElement class.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 24 def initialize(text, placement= ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) @_font_name = nil @color = nil @font_size = nil @_text_font = nil @_resource = nil @_type = ElementType::PAGE_NUMBERING super(text, placement, x_offset, y_offset) @text = text end |
Instance Attribute Details
#_font_name ⇒ Object
Returns the value of attribute _font_name.
37 38 39 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 37 def _font_name @_font_name end |
#color ⇒ Object
Gets or sets the Color object to use for the text of the label.
42 43 44 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 42 def color @color end |
#font_size ⇒ Object
Gets or sets the font size for the text of the label.
47 48 49 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 47 def font_size @font_size end |
#text ⇒ Object
Gets or sets the text to display in the label.
52 53 54 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 52 def text @text end |
Instance Method Details
#font(value) ⇒ Object
Gets or sets the Font object to use for the text of the label.
57 58 59 60 61 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 57 def font(value) @_text_font = value @_font_name = @_text_font._name @_resource = @_text_font._resource end |
#to_json(_options = {}) ⇒ Object
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 |
# File 'lib/ruby_client/Elements/PageNumberingElement.rb', line 63 def to_json( = {}) json_array = {} json_array['type'] = 'pageNumbering' 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).gsub('\\\\', '\\').gsub('\"', '"').gsub('\\\r', '\r').gsub('\\\n', '\n').gsub('\\\t', '\t') end |