Class: MDToPDF

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

Class Method Summary collapse

Class Method Details

.Convert(file_in_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mdtopdf.rb', line 6

def self.Convert file_in_path
  file_in = File.open(file_in_path, "rb")
  contents = file_in.read
  file_in.close

  file_out_path = File.basename(file_in_path, ".*")
  file_out_path += ".pdf"

  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
  html =  markdown.render contents

  kit = PDFKit.new(html, :page_size => 'Letter')
  kit.to_file file_out_path
end