Class: PDFKit::Configuration
- Inherits:
-
Object
- Object
- PDFKit::Configuration
- Defined in:
- lib/pdfkit/configuration.rb
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#meta_tag_prefix ⇒ Object
Returns the value of attribute meta_tag_prefix.
-
#root_url ⇒ Object
Returns the value of attribute root_url.
-
#use_xvfb ⇒ Object
writeonly
Sets the attribute use_xvfb.
-
#verbose ⇒ Object
writeonly
Sets the attribute verbose.
Instance Method Summary collapse
- #default_wkhtmltopdf ⇒ Object
- #executable ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #quiet? ⇒ Boolean
- #using_xvfb? ⇒ Boolean
- #verbose? ⇒ Boolean
- #wkhtmltopdf ⇒ Object
- #wkhtmltopdf=(path) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pdfkit/configuration.rb', line 9 def initialize @verbose = false @use_xvfb = false @meta_tag_prefix = 'pdfkit-' @default_options = { :disable_smart_shrinking => false, :quiet => true, :page_size => 'Letter', :margin_top => '0.75in', :margin_right => '0.75in', :margin_bottom => '0.75in', :margin_left => '0.75in', :encoding => 'UTF-8' } end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
7 8 9 |
# File 'lib/pdfkit/configuration.rb', line 7 def @default_options end |
#meta_tag_prefix ⇒ Object
Returns the value of attribute meta_tag_prefix.
5 6 7 |
# File 'lib/pdfkit/configuration.rb', line 5 def @meta_tag_prefix end |
#root_url ⇒ Object
Returns the value of attribute root_url.
5 6 7 |
# File 'lib/pdfkit/configuration.rb', line 5 def root_url @root_url end |
#use_xvfb=(value) ⇒ Object (writeonly)
Sets the attribute use_xvfb
6 7 8 |
# File 'lib/pdfkit/configuration.rb', line 6 def use_xvfb=(value) @use_xvfb = value end |
#verbose=(value) ⇒ Object (writeonly)
Sets the attribute verbose
6 7 8 |
# File 'lib/pdfkit/configuration.rb', line 6 def verbose=(value) @verbose = value end |
Instance Method Details
#default_wkhtmltopdf ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/pdfkit/configuration.rb', line 29 def default_wkhtmltopdf return @default_command_path if @default_command_path if defined?(Bundler::GemfileError) && File.exist?('Gemfile') @default_command_path = `bundle exec which wkhtmltopdf`.chomp.lines.last end @default_command_path = `which wkhtmltopdf`.chomp if @default_command_path.nil? || @default_command_path.empty? @default_command_path end |
#executable ⇒ Object
47 48 49 |
# File 'lib/pdfkit/configuration.rb', line 47 def executable using_xvfb? ? ['xvfb-run', wkhtmltopdf] : wkhtmltopdf end |
#quiet? ⇒ Boolean
55 56 57 |
# File 'lib/pdfkit/configuration.rb', line 55 def quiet? !@verbose end |
#using_xvfb? ⇒ Boolean
51 52 53 |
# File 'lib/pdfkit/configuration.rb', line 51 def using_xvfb? @use_xvfb end |
#verbose? ⇒ Boolean
59 60 61 |
# File 'lib/pdfkit/configuration.rb', line 59 def verbose? @verbose end |
#wkhtmltopdf ⇒ Object
25 26 27 |
# File 'lib/pdfkit/configuration.rb', line 25 def wkhtmltopdf @wkhtmltopdf ||= default_wkhtmltopdf end |
#wkhtmltopdf=(path) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/pdfkit/configuration.rb', line 38 def wkhtmltopdf=(path) if File.exist?(path) @wkhtmltopdf = path else warn "No executable found at #{path}. Will fall back to #{default_wkhtmltopdf}" @wkhtmltopdf = default_wkhtmltopdf end end |