diff --git a/lib/wicked_pdf.rb b/lib/wicked_pdf.rb index cee40f31..4f164d25 100644 --- a/lib/wicked_pdf.rb +++ b/lib/wicked_pdf.rb @@ -46,7 +46,8 @@ def pdf_from_string(string, options = {}) string_file.write(string) string_file.close - pdf = pdf_from_html_file(string_file.path, options) + action = options[:skip_file_prefix] ? 'pdf_from_url' : 'pdf_from_html_file' + pdf = send(action, string_file.path, options) pdf ensure string_file.close! if string_file diff --git a/lib/wicked_pdf/pdf_helper.rb b/lib/wicked_pdf/pdf_helper.rb index 0b97f411..eb7184f4 100644 --- a/lib/wicked_pdf/pdf_helper.rb +++ b/lib/wicked_pdf/pdf_helper.rb @@ -122,7 +122,7 @@ def prerender_header_and_footer(options) [:header, :footer].each do |hf| next unless options[hf] && options[hf][:html] && options[hf][:html][:template] @hf_tempfiles = [] unless defined?(@hf_tempfiles) - @hf_tempfiles.push(tf = WickedPdfTempfile.new("wicked_#{hf}_pdf.html")) + @hf_tempfiles.push(tf = WickedPdfTempfile.new("wicked_#{hf}_pdf.html", options[:temp_path])) options[hf][:html][:layout] ||= options[:layout] render_opts = { :template => options[hf][:html][:template], @@ -135,7 +135,7 @@ def prerender_header_and_footer(options) render_opts[:file] = options[hf][:html][:file] if options[:file] tf.write render_to_string(render_opts) tf.flush - options[hf][:html][:url] = "file:///#{tf.path}" + options[hf][:html][:url] = options[:skip_file_prefix] ? tf.path : "file:///#{tf.path}" end options end