Class: PDFGen::Image
- Inherits:
-
BaseRegion
- Object
- BaseRegion
- PDFGen::Image
- Defined in:
- lib/image.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
Attributes inherited from BaseRegion
Attributes included from BaseAttributes
#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width
Instance Method Summary collapse
-
#initialize(parent, image_res) ⇒ Image
constructor
A new instance of Image.
- #render(pos, av_height, test = false) ⇒ Object
- #set_properties(props = {}) ⇒ Object
Methods inherited from BaseRegion
#check_fit_in_height, #document, #minimal_height, #value
Methods included from BaseAttributes
#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init
Methods included from BaseAttributes::ClassMethods
Constructor Details
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
16 17 18 |
# File 'lib/image.rb', line 16 def image @image end |
Instance Method Details
#render(pos, av_height, test = false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/image.rb', line 32 def render(pos, av_height, test=false) self.check_fit_in_height if av_height >= self.height document.pdf.add_image(@image, pos[0] + pad_left, pos[1] - height + pad_bottom, width - pad_left - pad_right, height-pad_top - pad_bottom) super [self.height, true] else [0, false] end end |
#set_properties(props = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/image.rb', line 18 def set_properties(props = {}) super if width.zero? && height.zero? self.width = @info.width self.height = @info.height elsif width.zero? self.width = height / @info.height.to_f * @info.width elsif height.zero? self.height = width * @info.height / @info.width.to_f end self.height = self.height - pad_top - pad_bottom end |