Skip to content

Instantly share code, notes, and snippets.

@foundrium
Created January 9, 2016 21:00
Show Gist options
  • Save foundrium/a8ca5d459eede3ac8384 to your computer and use it in GitHub Desktop.
Save foundrium/a8ca5d459eede3ac8384 to your computer and use it in GitHub Desktop.
diff --git a/lib/wicked_pdf.rb b/lib/wicked_pdf.rb
index 7c6486f..58904b2 100644
--- a/lib/wicked_pdf.rb
+++ b/lib/wicked_pdf.rb
@@ -80,7 +80,7 @@ class WickedPdf
rescue Exception => e
raise "Failed to execute:\n#{command}\nError: #{e}"
ensure
- generated_pdf_file.close! if generated_pdf_file && !return_file
+ generated_pdf_file.close if generated_pdf_file && !return_file
end
def pdf_from_string(string, options={})
@@ -95,7 +95,7 @@ class WickedPdf
rescue Exception => e
raise "Error: #{e}"
ensure
- string_file.close! if string_file
+ string_file.close if string_file
end
private
@@ -169,12 +169,12 @@ class WickedPdf
def make_options(options, names, prefix="", type=:string)
return [] if options.nil?
- names.collect do |o|
+ names.collect do |o|
if options[o].blank?
[]
else
- make_option("#{prefix.blank? ? "" : prefix + "-"}#{o.to_s}",
- options[o],
+ make_option("#{prefix.blank? ? "" : prefix + "-"}#{o.to_s}",
+ options[o],
type)
end
end
diff --git a/lib/wicked_pdf/pdf_helper.rb b/lib/wicked_pdf/pdf_helper.rb
index c5c60f8..a801786 100644
--- a/lib/wicked_pdf/pdf_helper.rb
+++ b/lib/wicked_pdf/pdf_helper.rb
@@ -50,7 +50,7 @@ module PdfHelper
def clean_temp_files
if defined?(@hf_tempfiles)
- @hf_tempfiles.each { |tf| tf.close! }
+ @hf_tempfiles.each { |tf| tf.close }
end
end
@@ -59,6 +59,7 @@ module PdfHelper
render_opts.merge!(:locals => options[:locals]) if options[:locals]
render_opts.merge!(:file => options[:file]) if options[:file]
html_string = render_to_string(render_opts)
+ File.open("/Users/elaforc/code/levveldocs/full.html", "w") { |file| file.write html_string }
options = prerender_header_and_footer(options)
w = WickedPdf.new(options[:wkhtmltopdf])
w.pdf_from_string(html_string, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment