Module: GTK::ControllersHelper
- Defined in:
- lib/gtk_webkit_pdf/gtk_controllers_helper_pdf.rb
Class Method Summary collapse
Instance Method Summary collapse
- #make_and_send_pdf(pdf_name = nil, options = {}) ⇒ Object
- #render_with_gtk_webkit_pdf(options = {}, *args, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/gtk_webkit_pdf/gtk_controllers_helper_pdf.rb', line 3 def self.included(base) return if base != ActionController::Base base.class_eval do alias_method_chain :render, :gtk_webkit_pdf end end |
Instance Method Details
#make_and_send_pdf(pdf_name = nil, options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/gtk_webkit_pdf/gtk_controllers_helper_pdf.rb', line 19 def make_and_send_pdf(pdf_name = nil, = {}) html_string = render_to_string() gtk_printer = GTK::Webkit.new(html_string, 0).gtk_printer send_data(gtk_printer.pdf_content, :file_name => pdf_name+'.pdf', :type => 'application/pdf', :disposition => [:disposition]) end |
#render_with_gtk_webkit_pdf(options = {}, *args, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/gtk_webkit_pdf/gtk_controllers_helper_pdf.rb', line 11 def render_with_gtk_webkit_pdf( = {}, *args, &block) if .is_a?(Hash) && .has_key?(:pdf) make_and_send_pdf(.delete(:pdf), ()) else render_without_gtk_webkit_pdf(, *args, &block) end end |