Rectangle 27 0

That said, for anything but a trivial PDF you will probably want to generate it outside the controller somewhere.

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn
Rectangle 27 0

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?

def index
  pdf = Prawn::Document.new
  pdf.text "Hello World"
  send_data pdf.render, :filename => "x.pdf", :type => "application/pdf"
end

How can I make it to save and show up in the browser window?

def index
  pdf = Prawn::Document.new
  pdf.text "Hello World"
  filename = File.join(Rails.root, "app/report", "x.pdf")
  pdf.render_file filename
  send_file filename, :filename => "x.pdf", :type => "application/pdf"
end

Hi, for me its not going to save in that folder. but it goes there to find that is that pdf is there or not? any solution to store pdf in public folder?

in the send_data you should add the option :disposition => 'inline'

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn
Rectangle 27 0

Answering Question 3: "How can I make it to save and show up in the browser window?"

def index
  pdf = Prawn::Document.new
  pdf.text 'Hello World'
  send_data pdf.render, filename: 'x.pdf', type: 'application/pdf', disposition: 'inline'
end

disposition: 'inline' will force the browser ( if it can ) to display your PDF inside the current browser window

:disposition => 'inline'

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn
Rectangle 27 0

def index
  pdf = Prawn::Document.new
  pdf.text "Hello World"
  send_data pdf.render, :filename => "x.pdf", :type => "application/pdf"
 end

That said, for anything but a trivial PDF you will probably want to generate it outside the controller somewhere.

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn
Rectangle 27 0

I would approach email conversion via the IMAP library (there might be newer ones out by now) and then serve everything from a simple Sinatra app in the browser. You can use a template language to generate simple html output and logic. Of course you can also use prawn for pdf generation. Many different ways to get there... Not sure why you don't just load emails and show partial content. Life can be so simple.

Thanks. I'm doing this because there are too much emails being sent within the organisation i'm in right now. Some important emails get neglected because they are buried within some less important emails, and some emails matters to some more than others, etc. So I decided to come out with some sort of an email aggregator, hoping the the information are targeted at the correct people.

ruby - Convert emails to HTML or PDF programtically - Stack Overflow

ruby email
Rectangle 27 0

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?

Hi, for me its not going to save in that folder. but it goes there to find that is that pdf is there or not? any solution to store pdf in public folder?

in the send_data you should add the option :disposition => 'inline'

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn
Rectangle 27 0

Benoit Garret's answer is very good, but I should note on the second example:

How can I make the action to generate the file in the browser window and don't save it?

:disposition => 'inline' will force the browser ( if it can ) to display your PDF inside the current browser window

Rails, Prawn - PDF show up in browser & etc - Stack Overflow

ruby-on-rails-3 pdf prawn