Sha256: 65549a64d4251e46ceb58b56a733d63e2e903afe0e09975ec93546006ac97f07

Contents?: true

Size: 1003 Bytes

Versions: 5

Compression:

Stored size: 1003 Bytes

Contents

class PDFKit
  class Configuration
    attr_accessor :meta_tag_prefix, :default_options, :root_url
    attr_writer :wkhtmltopdf

    def initialize
      @meta_tag_prefix = 'pdfkit-'
      @default_options = {
        :disable_smart_shrinking => false,
        :page_size => 'Letter',
        :margin_top => '0.75in',
        :margin_right => '0.75in',
        :margin_bottom => '0.75in',
        :margin_left => '0.75in',
        :encoding => "UTF-8"
      }
    end

    def wkhtmltopdf
      @wkhtmltopdf ||= (defined?(Bundler::GemfileError) ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp
    end
  end

  class << self
    attr_accessor :configuration
  end

  # Configure PDFKit someplace sensible,
  # like config/initializers/pdfkit.rb
  #
  # @example
  #   PDFKit.configure do |config|
  #     config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
  #   end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
hssc_pdfkit-0.5.5 lib/pdfkit/configuration.rb
hssc_pdfkit-0.5.4 lib/pdfkit/configuration.rb
pdfkit-0.5.4 lib/pdfkit/configuration.rb
pdfkit-0.5.3 lib/pdfkit/configuration.rb
pdfkit-0.5.2 lib/pdfkit/configuration.rb