lib/pdfkit/pdfkit.rb in pdfkit-0.3.0 vs lib/pdfkit/pdfkit.rb in pdfkit-0.3.1

- old
+ new

@@ -28,16 +28,15 @@ :margin_bottom => '0.75in', :margin_left => '0.75in' } @options = normalize_options(options.reverse_merge(default_options)) - @cmd = `which wkhtmltopdf-proxy`.chomp - raise NoExecutableError.new if @cmd.blank? + raise NoExecutableError.new if wkhtmltopdf.blank? end def command - args = [@cmd] + args = [wkhtmltopdf] args += @options.to_a.flatten.compact args << '--quiet' if @source.html? args << '-' # Get HTML from stdin @@ -63,9 +62,13 @@ def to_file(path) File.open(path,'w') {|file| file << self.to_pdf} end protected + + def wkhtmltopdf + @wkhtmltopdf ||= `which wkhtmltopdf-proxy`.chomp + end def style_tag_for(stylesheet) "<style>#{File.read(stylesheet)}</style>" end \ No newline at end of file