Class: WkPdfRenderer

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/wicked_pdf_standalone/wicked_pdf_standalone.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ WkPdfRenderer

Returns a new instance of WkPdfRenderer.



3
4
5
6
# File 'lib/wicked_pdf_standalone/wicked_pdf_standalone.rb', line 3

def initialize(*args)
  config.assets_dir = Rails.root.join("public")
  super
end

Instance Method Details

#to_file(output_path, options = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/wicked_pdf_standalone/wicked_pdf_standalone.rb', line 12

def to_file(output_path, options={}, &block)
  html_renderer_options = {}
  html_renderer_options[:layout] = options.delete(:layout)
  to_html(options[:template], html_renderer_options, &block)
  render_with_wicked_pdf({:pdf => 'null',
                          :save_to_file => output_path,
                          :save_only => true}.merge(options))
  output_path
end

#to_html(template_path, options = {}, &block) ⇒ Object



8
9
10
# File 'lib/wicked_pdf_standalone/wicked_pdf_standalone.rb', line 8

def to_html(template_path, options = {}, &block)
  @html_string = markup(template_path, options, &block)
end