Class: PDFKit::WkHTMLtoPDF
- Inherits:
-
Object
- Object
- PDFKit::WkHTMLtoPDF
- Defined in:
- lib/pdfkit/wkhtmltopdf.rb
Constant Summary collapse
- REPEATABLE_OPTIONS =
%w[--allow --bypass-proxy-for --cookie --custom-header --post --post-file --run-script --replace].freeze
- SPECIAL_OPTIONS =
%w[cover toc].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #error_handling? ⇒ Boolean
-
#initialize(options) ⇒ WkHTMLtoPDF
constructor
A new instance of WkHTMLtoPDF.
- #normalize_options ⇒ Object
- #options_for_command ⇒ Object
Constructor Details
#initialize(options) ⇒ WkHTMLtoPDF
Returns a new instance of WkHTMLtoPDF.
11 12 13 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 11 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 5 def @options end |
Instance Method Details
#error_handling? ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 39 def error_handling? @options.key?('--ignore-load-errors') || # wkhtmltopdf v0.10.0 beta4 replaces ignore-load-errors with load-error-handling # https://code.google.com/p/wkhtmltopdf/issues/detail?id=55 %w(skip ignore).include?(@options['--load-error-handling']) end |
#normalize_options ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 15 def # TODO(cdwort,sigmavirus24): Make this method idempotent in a future release so it can be called repeatedly = {} @options.each do |key, value| next if !value # The actual option for wkhtmltopdf normalized_key = normalize_arg key normalized_key = "--#{normalized_key}" unless SPECIAL_OPTIONS.include?(normalized_key) # If the option is repeatable, attempt to normalize all values if REPEATABLE_OPTIONS.include? normalized_key normalize_repeatable_value(normalized_key, value) do |normalized_unique_key, normalized_value| [normalized_unique_key] = normalized_value end else # Otherwise, just normalize it like usual [normalized_key] = normalize_value(value) end end @options = end |
#options_for_command ⇒ Object
46 47 48 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 46 def @options.to_a.flatten.compact end |