Sha256: afaf5c0a3f2646c2a14cae9a353cbb06f3db4750a936429547967e5c3df69ace

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

# coding: utf-8
module Pdfs2Pdf
  class Configuration
    attr_accessor :default_options,
                  :pdfmarks_meta,
                  :wkhtmltopdf

    def initialize
      # see: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
      @default_options = {
        paper_size: 'A4', # 'Letter'
        # Note: placeholder values, will be added in the up coming release!
        margin_top: '0.75in',
        margin_right: '0.75in',
        margin_bottom: '0.75in',
        margin_left: '0.75in',
        encoding: 'UTF-8'
      }

      # see: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf
      @pdfmarks_meta = <<-END.gsub(/^\s+\|/, '')
        |[ /Title (My Combined Pdf)
        |  /Author (Burin Choomnuan)
        |  /Keywords (fun, witty, interesting)
        |  /DOCINFO pdfmark
      END

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

  class << self
    attr_accessor :configuration

    # Configure Pdfs2Pdf someplace sensible, like
    # config/initializers/pdfs2pdf.rb
    #
    # @example
    #
    # Pdfs2pdf.configure do |config|
    #   # set the path to wkhtmltopdf
    #   config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
    # end
    def configuration
      @configuration ||= Configuration.new
    end

    def configure
      yield(configuration)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdfs2pdf-0.0.7 lib/pdfs2pdf/configuration.rb
pdfs2pdf-0.0.6 lib/pdfs2pdf/configuration.rb