Sha256: 9e71dbbd3c7c293b32c85eab01cbce98ef886c3ccfd9217add73a06a5fc551d3
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
class Wkhtmltopdf attr_accessor :pdf_file, :html_file, :source, :optional_params, :params_string def initialize(options) # @pdf_file = "#{options[:file_path]}/#{options[:pdf]}.pdf" @html_file = options[:html_file] if options.has_key?(:html_file) @source = options[:source] if options.has_key?(:source) @optional_params = options[:wkhtmltopdf_options] if options.has_key?(:wkhtmltopdf_options) create_params_string end def generate wkhtml_call = "wkhtmltopdf " if !@source.nil? puts "source" wkhtml_call << "#{@source}" else puts "local html" wkhtml_call << "#{@html_file}" end wkhtml_call << " #{@params_string} - -q" return `#{wkhtml_call}` end private def create_params_string params_arr = [] unless @optional_params.nil? @optional_params.each do |key, val| if val && val.is_a?(String) params_arr << "--#{key.to_s} '#{val}'" elsif val params_arr << "--#{key.to_s}" end end end @params_string = params_arr.join(' ') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wkhtmltopdf_for_rails-0.0.2 | lib/wkhtmltopdf.rb |
wkhtmltopdf_for_rails-0.0.1 | lib/wkhtmltopdf.rb |