Sha256: 379e8c55945557b8dd87c8e609f70be6259aefaa919689cca6add1d0928ab010

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

module Pdfs2Pdf
  class Configuration
    attr_accessor :default_options,
                  :pdfmarks_meta,
                  :gs_binary

    def initialize
      # see: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
      @default_options = {
        paper_size:    "A4", # or 'Letter'
        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

      @gs_binary = (defined?(Bundler::GemfileError) ? `bundle exec which gs` : `which gs`).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.gs_binary = '/usr/bin/gs'
    # end
    def configuration
      @configuration ||= Configuration.new
    end

    def configure
      yield(configuration)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pdfs2pdf-0.2.5 lib/pdfs2pdf/configuration.rb
pdfs2pdf-0.2.4 lib/pdfs2pdf/configuration.rb
pdfs2pdf-0.2.3 lib/pdfs2pdf/configuration.rb