Class: TnPDF::PageSection::Box
- Inherits:
-
Object
- Object
- TnPDF::PageSection::Box
- Defined in:
- lib/tn_pdf/box.rb
Instance Attribute Summary collapse
-
#image_file ⇒ Object
readonly
Returns the value of attribute image_file.
-
#image_options ⇒ Object
readonly
Returns the value of attribute image_options.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#text_options ⇒ Object
readonly
Returns the value of attribute text_options.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #has_image? ⇒ Boolean
- #has_text? ⇒ Boolean
-
#initialize(options) ⇒ Box
constructor
A new instance of Box.
- #render(document, pos, height = nil) ⇒ Object
Constructor Details
#initialize(options) ⇒ Box
Returns a new instance of Box.
9 10 11 |
# File 'lib/tn_pdf/box.rb', line 9 def initialize() () end |
Instance Attribute Details
#image_file ⇒ Object (readonly)
Returns the value of attribute image_file.
5 6 7 |
# File 'lib/tn_pdf/box.rb', line 5 def image_file @image_file end |
#image_options ⇒ Object (readonly)
Returns the value of attribute image_options.
5 6 7 |
# File 'lib/tn_pdf/box.rb', line 5 def @image_options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/tn_pdf/box.rb', line 6 def text @text end |
#text_options ⇒ Object (readonly)
Returns the value of attribute text_options.
6 7 8 |
# File 'lib/tn_pdf/box.rb', line 6 def @text_options end |
#width ⇒ Object
Returns the value of attribute width.
7 8 9 |
# File 'lib/tn_pdf/box.rb', line 7 def width @width end |
Instance Method Details
#has_image? ⇒ Boolean
35 36 37 |
# File 'lib/tn_pdf/box.rb', line 35 def has_image? !image_file.nil? end |
#has_text? ⇒ Boolean
39 40 41 |
# File 'lib/tn_pdf/box.rb', line 39 def has_text? !text.nil? end |
#render(document, pos, height = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tn_pdf/box.rb', line 13 def render(document, pos, height=nil) = { :width => width } [:height] = height unless height.nil? document.bounding_box(pos, ) do if has_image? image_args = [image_file] image_args << unless .empty? document.image(*image_args) end if has_text? text_args = [text] .merge!({:inline_format => true}) text_args << document.font([:font], [:font_options]) do document.text(*text_args) end end end end |