0
votes

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)?

2
Displaying pdfs inline is hard, see stackoverflow.com/questions/291813/…Benoit Garret
Does it behave the same across different browsers?David Barlow
@Barlow it doesn't seem to and it also depends on the OS (on my box, firefox 6 doesn't do the same thing on windows and linux).Benoit Garret
Yes, it's behaving the same way across browsers for me (firefox and chrome). I'm using Linux, and am not sure if the OS is making a difference...Solomon
@BenoitGarret, the OS, not Prawnto is the issue. I tried from Windows, and the pdf displays in the browser. If you want to repost your comment as an answer, I'll accept it.Solomon

2 Answers

1
votes

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.

-1
votes

@benoit Linux / Mozilla and Opera both open all pdfs on websites I visit - except on my site using this method. I get "open in application" or "save" as the only choices - it will not render inline.