Method: Any2Pdf#html2pdf

Defined in:
lib/any2pdf/html2pdf.rb

#html2pdf(file, opts) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/any2pdf/html2pdf.rb', line 71

def html2pdf(file, opts)
  Log.debug "running html2pdf on '#{file}'"
  return nil if not file.end_with?(".html")
  pdffile = file.sub(/.html$/,".pdf")
  pdffile = opts.output if not opts.output.nil? and not opts.output.empty?
  Log.debug "output pdf will be '#{pdffile}'"

  case opts[:renderer]
  when 'pdfkit'
    pdfkit_html2pdf file, pdffile, opts
  when 'xelatex'
    xelatex_html2pdf file, pdffile, opts
  else
    Log.abort "Can't find renderer '#{opts[:renderer]}'. Please use a supported renderer!"
  end

  pdffile
end