Class: Parade::Commands::StaticPdf

Inherits:
Object
  • Object
show all
Defined in:
lib/parade/commands/static_pdf.rb

Overview

Saves a PDF version of the presentation that is from the HtmlOutput

Instance Method Summary collapse

Instance Method Details

#default_pdf_outputObject



32
33
34
# File 'lib/parade/commands/static_pdf.rb', line 32

def default_pdf_output
  "presentation.pdf"
end

#descriptionObject



11
12
13
# File 'lib/parade/commands/static_pdf.rb', line 11

def description
  "Output into a PDF format"
end

#generate(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/parade/commands/static_pdf.rb', line 15

def generate(options)
  options.merge!('template' => 'pdf')

  html_generator = HtmlOutput.new
  html_content = html_generator.generate(options)

  kit = PDFKit.new(html_content,:page_size => 'Letter', :orientation => 'Landscape')

  output_file = options[:output] || default_pdf_output

  return if (File.exists?(output_file) and not options.key?(:force))

  kit.to_file(output_file)

  puts "Saved PDF to #{output_file}"
end