Method: WickedPdf#pdf_from_string

Defined in:
lib/wicked_pdf.rb

#pdf_from_string(string, options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wicked_pdf.rb', line 52

def pdf_from_string(string, options = {})
  options = options.dup
  options.merge!(WickedPdf.config) { |_key, option, _config| option }
  string_file = WickedPdfTempfile.new('wicked_pdf.html', options[:temp_path])
  string_file.binmode
  string_file.write(string)
  string_file.close

  pdf = pdf_from_html_file(string_file.path, options)
  pdf
ensure
  string_file.close! if string_file
end