Module: Prawn::Rails::PrawnHelper
- Defined in:
- lib/prawn_rails.rb
Instance Method Summary collapse
Instance Method Details
#disposition(download, filename) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/prawn_rails.rb', line 24 def disposition(download, filename) download = true if (filename && download == nil) disposition = download ? "attachment;" : "inline;" disposition += " filename=\"#{filename}\"" if filename headers["Content-Disposition"] = disposition end |
#prawn_document(opts = {}) {|pdf| ... } ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/prawn_rails.rb', line 13 def prawn_document(opts={}) download = opts.delete(:force_download) filename = opts.delete(:filename) pdf = (opts.delete(:renderer) || Prawn::Document).new(opts) yield pdf if block_given? disposition(download, filename) if (download || filename) pdf.render end |