Class: PdfRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PdfRenderer

Returns a new instance of PdfRenderer.



5
6
7
8
# File 'lib/pdf_renderer.rb', line 5

def initialize(config)
  @stylesheet = config.template_stylesheet 
  @config = config
end

Instance Method Details

#render(html, output_file_path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pdf_renderer.rb', line 10

def render(html, output_file_path)
  PDFKit.configure do |c|
    c.wkhtmltopdf = @config.wkhtmltopdf_path
  end

  kit = PDFKit.new(html, :page_size => 'Letter', :margin_left => 0, :margin_right => 0, :margin_bottom => 0, :margin_top => 0)
  kit.stylesheets << @stylesheet
  kit.to_file output_file_path

  puts "Printed scrum cards to #{output_file_path}"
end