0

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

Solomon
  • 6,145
  • 3
  • 25
  • 34
  • Displaying pdfs inline is hard, see http://stackoverflow.com/questions/291813/best-way-to-embed-pdf-in-html#answer-291823 – Benoit Garret Sep 22 '11 at 22:19
  • Does it behave the same across different browsers? – David Barlow Sep 22 '11 at 23:46
  • @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 Sep 23 '11 at 14:27
  • 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 Sep 23 '11 at 15:18
  • @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 Sep 25 '11 at 16:44

2 Answers2

1

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.

Benoit Garret
  • 14,027
  • 4
  • 59
  • 64
-1

@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.