Class: Storyboard::PDFRenderer
- Defined in:
- lib/storyboard/generators/pdf.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#pdf ⇒ Object
Returns the value of attribute pdf.
-
#storyboard ⇒ Object
Returns the value of attribute storyboard.
Instance Method Summary collapse
-
#initialize(parent) ⇒ PDFRenderer
constructor
A new instance of PDFRenderer.
- #render_frame(frame_name, subtitle = nil) ⇒ Object
- #set_dimensions(w, h) ⇒ Object
- #write ⇒ Object
Methods inherited from Renderer
Constructor Details
#initialize(parent) ⇒ PDFRenderer
Returns a new instance of PDFRenderer.
8 9 10 11 |
# File 'lib/storyboard/generators/pdf.rb', line 8 def initialize(parent) @dimensions = [] @storyboard = parent end |
Instance Attribute Details
#dimensions ⇒ Object
Returns the value of attribute dimensions.
7 8 9 |
# File 'lib/storyboard/generators/pdf.rb', line 7 def dimensions @dimensions end |
#pdf ⇒ Object
Returns the value of attribute pdf.
7 8 9 |
# File 'lib/storyboard/generators/pdf.rb', line 7 def pdf @pdf end |
#storyboard ⇒ Object
Returns the value of attribute storyboard.
7 8 9 |
# File 'lib/storyboard/generators/pdf.rb', line 7 def storyboard @storyboard end |
Instance Method Details
#render_frame(frame_name, subtitle = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/storyboard/generators/pdf.rb', line 23 def render_frame(frame_name, subtitle = nil) output_filename = File.join(@storyboard.[:save_directory], "sub-#{File.basename(frame_name)}") image = MiniMagick::Image.open(frame_name) if(@dimensions.empty?) resize_height = (image[:height] * (@storyboard.[:max_width].to_f/image[:width])).ceil set_dimensions(storyboard.[:max_width], resize_height) end image.resize "#{@dimensions[0]}x#{@dimensions[1]}" image.quality("60") self.add_subtitle(image, subtitle, @dimensions) if subtitle image.format 'jpeg' image.write(output_filename) image.destroy! @pdf.image output_filename, :width => @dimensions[0], :height => @dimensions[1] end |
#set_dimensions(w, h) ⇒ Object
13 14 15 16 |
# File 'lib/storyboard/generators/pdf.rb', line 13 def set_dimensions(w,h) @dimensions = [w,h] @pdf = Prawn::Document.new(:page_size => [w, h], :margin => 0) end |
#write ⇒ Object
18 19 20 21 |
# File 'lib/storyboard/generators/pdf.rb', line 18 def write @pdf.render_file "#{@storyboard.[:write_to]}/#{@storyboard.[:basename]}.pdf" LOG.info("Wrote #{@storyboard.[:write_to]}/#{@storyboard.[:basename]}.pdf") end |