Class: EmlToPdf::Wkhtmltopdf

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

Defined Under Namespace

Classes: ConversionError

Class Method Summary collapse

Class Method Details

.convert(input, output_path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/eml_to_pdf/wkhtmltopdf.rb', line 5

def self.convert(input, output_path)
  IO.popen("wkhtmltopdf --encoding utf-8 --footer-center [page] --footer-spacing 2.5 - #{output_path} 2>&1", "r+") do |pipe|
    pipe.puts(input)
    pipe.close_write
    output = pipe.readlines.join
    pipe.close
    unless $?.success?
      raise ConversionError, output
    end
  end
end