Permalink
Browse files

added parameter :content to the options :header and :footer when call…

…ing method pdf_from_string from outside a controller; you will need to pass the html content of the header and the footer (already rendered)
  • Loading branch information...
1 parent d67e7dd commit 4a015959fd2bf955319cc1374f0a2a1e068871e7 claudiocontin committed with unixmonkey Dec 21, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/wicked_pdf.rb
View
@@ -107,6 +107,15 @@ def parse_header_footer(options)
r += make_options(opt_hf, [:center, :font_name, :left, :right], "#{hf.to_s}")
r += make_options(opt_hf, [:font_size, :spacing], "#{hf.to_s}", :numeric)
r += make_options(opt_hf, [:line], "#{hf.to_s}", :boolean)
+ if options[hf] && options[hf][:content]
+ @hf_tempfiles = [] if ! defined?(@hf_tempfiles)
+ @hf_tempfiles.push( tf=WickedPdfTempfile.new("wicked_#{hf}_pdf.html") )
+ tf.write options[hf][:content]
+ tf.flush
+ options[hf].delete(:content)
+ options[hf][:html] = {}
+ options[hf][:html][:url] = "file://#{tf.path}"
+ end
unless opt_hf[:html].blank?
r += make_option("#{hf.to_s}-html", opt_hf[:html][:url]) unless opt_hf[:html][:url].blank?
end

0 comments on commit 4a01595

Please sign in to comment.