lib/wicked_pdf.rb in wicked_pdf-0.9.10 vs lib/wicked_pdf.rb in wicked_pdf-0.10.0
- old
+ new
@@ -114,10 +114,11 @@
[
parse_extra(options),
parse_header_footer(:header => options.delete(:header),
:footer => options.delete(:footer),
:layout => options[:layout]),
+ parse_cover(options.delete(:cover)),
parse_toc(options.delete(:toc)),
parse_outline(options.delete(:outline)),
parse_margins(options.delete(:margin)),
parse_others(options),
parse_basic_auth(options)
@@ -176,10 +177,26 @@
end
end unless options.blank?
r
end
+ def parse_cover(argument)
+ arg = argument.to_s
+ return '' if arg.blank?
+ r = '--cover '
+ # Filesystem path or URL - hand off to wkhtmltopdf
+ if arg.include?(Rails.root.to_s) || (arg[0,4] == 'http')
+ r + arg
+ else # HTML content
+ @hf_tempfiles ||= []
+ @hf_tempfiles << tf=WickedPdfTempfile.new("wicked_cover_pdf.html")
+ tf.write arg
+ tf.flush
+ r + tf.path
+ end
+ end
+
def parse_toc(options)
r = '--toc ' unless options.nil?
unless options.blank?
r += make_options(options, [ :font_name, :header_text], "toc")
r +=make_options(options, [ :depth,
@@ -223,20 +240,20 @@
:page_width,
:page_height,
:proxy,
:username,
:password,
- :cover,
:dpi,
:encoding,
:user_style_sheet])
r +=make_options(options, [ :cookie,
:post], "", :name_value)
r +=make_options(options, [ :redirect_delay,
:zoom,
:page_offset,
- :javascript_delay], "", :numeric)
+ :javascript_delay,
+ :image_quality], "", :numeric)
r +=make_options(options, [ :book,
:default_header,
:disable_javascript,
:grayscale,
:lowquality,
@@ -245,9 +262,10 @@
:disable_external_links,
:print_media_type,
:disable_smart_shrinking,
:use_xserver,
:no_background], "", :boolean)
+ r +=make_options(options, [ :no_stop_slow_scripts ], "", nil)
end
end
def find_wkhtmltopdf_binary_path
possible_locations = (ENV['PATH'].split(':')+%w[/usr/bin /usr/local/bin ~/bin]).uniq