ruby-on-railsruby-on-rails-3prawnprawnto

Prawnto won't display pdf inline


I'm trying to use prawn and prawnto (both installed via gems) in order to generate pdf's for my app. I want the pdf to display in the browser, but it won't, it automatically downloads instead.

I have the following prawnto options in my controller:

prawnto :inline => true, :filename => "results.pdf", :prawn => {:top_margin => 75}

The filename and margin arguments both work, but the document won't display inline. I'm pretty sure this is a prawnto issue and not a prawn issue. The prawn gem seems pretty old. Someone has created a new gem (prawnto_2) to update for rails 3.1, but I'm still using rails 3.0.7.

Has anyone else had this issue? How can I get prawnto to show the pdf inline (ideally in a new tab or window)?


Solution

  • The :inline option uses the Content-Disposition HTTP header, which relies on a browser plugin to interpret the content.

    This means that the results can vary depending on the browser/OS combination you're using, Linux especially doesn't seem very good at handling this.