class PDFKit::Configuration
Attributes
default_options[R]
meta_tag_prefix[RW]
root_url[RW]
use_xvfb[W]
verbose[W]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
default_options=(options)
click to toggle source
# File lib/pdfkit/configuration.rb, line 63 def default_options=(options) @default_options.merge!(options) end
default_wkhtmltopdf()
click to toggle source
# 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()
click to toggle source
# File lib/pdfkit/configuration.rb, line 47 def executable using_xvfb? ? ['xvfb-run', wkhtmltopdf] : wkhtmltopdf end
quiet?()
click to toggle source
# File lib/pdfkit/configuration.rb, line 55 def quiet? !@verbose end
using_xvfb?()
click to toggle source
# File lib/pdfkit/configuration.rb, line 51 def using_xvfb? @use_xvfb end
verbose?()
click to toggle source
# File lib/pdfkit/configuration.rb, line 59 def verbose? @verbose end
wkhtmltopdf()
click to toggle source
# File lib/pdfkit/configuration.rb, line 25 def wkhtmltopdf @wkhtmltopdf ||= default_wkhtmltopdf end
wkhtmltopdf=(path)
click to toggle source
# 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