Howto - display PDF file in new window ?

My app is creating a PDF in my app’s public directory. When the visitor clicks a button, I need to be able to display the file in a new window. I cannot figure out how to do it. Any help is greatly appreciated.

Thanks,

Bill

If it’s a link, just add target="_blank" to the a tag. If it’s Javascript, there’s window.open(url, options*) IIRC.

Jason

Guest wrote:

Do you define the Content-Type of your page ?

No. Do I need to? This is the first time I've tried to display anything other than HTML from a Rails app. I'm feeling really lost.

Thanks,
Bill

Wes Gamble wrote:

Here's an example of some code in a view
to set up a link that will open up a new window
to receive a PDF:

<snip>

Hope this helps.

That was a huge help. Thank you, Wes!

Let me know if you need more info.

Well... since you asked :wink: I really need to (visually) use a button rather than a link. The problem is that button_to uses POST and so the :popup option doesn't work. Any suggestions?

Thanks again,
Bill

There is no option to that. One possibility is to make a custom button.