I'm trying to understand the Prawn pdf gem.
I was able to make it generate a pdf. Every gem in the gemfile included:
gem 'mysql', '~> 2.8.1'
gem 'prawn', '~> 0.12.0'
gem 'pdf-reader', '~> 0.10.0'
gem 'Ascii85', '~> 1.0.1'
In the config/application.rb:
config.autoload_paths << "#{Rails.root}/app/reports"
Then in the controller:
require 'prawn'
def index
pdf = Prawn::Document.new
pdf.text "Hello World"
pdf.render_file "x.pdf"
end
Than I call the index function. A PDF named x.pdf is created in the root of my application. Amongst the gemfile, rakefile and config.ru.
Question:
- How can I force prawn to generate the file in the app/report (or any other selected) folder?
- How can I make the action to generate the file in the browser window and don't save it?
- How can I make it to save and show up in the browser window?
How can I force prawn to generate the file in the app/report (or any other selected) folder?
How can I make the action to generate the file in the browser window and don't save it?
How can I make it to save and show up in the browser window?
Try this:
That said, for anything but a trivial PDF you will probably want to generate it outside the controller somewhere.
Answering Question 3: "How can I make it to save and show up in the browser window?"
disposition: 'inline'
will force the browser ( if it can ) to display your PDF inside the current browser window