Forum: Ruby on Rails How to open a pdf file in new window

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1c814a8b18126576c774babc160d1eab?d=identicon&s=25 Sainaba Sainu (sainaba)
on 2006-01-04 13:19
Hi all

I made a pdf file in ruby and to display it used the method send_data
like

#
send_data pdf.render, :filename => "Hello.pdf",:type =>
"application/pdf"
#

Now I want to open it in another window or as a popup. How can I achieve
it?

Thanks to all.

Sainaba.
03cb7371db223067d0daab54e1f95cb2?d=identicon&s=25 Abdur-Rahman Advany (Guest)
on 2006-01-04 13:21
(Received via mailing list)
just make the view do a request of the action in a popup?
1c814a8b18126576c774babc160d1eab?d=identicon&s=25 Sainaba Sainu (sainaba)
on 2006-01-04 13:38
Abdur-Rahman Advany wrote:
> just make the view do a request of the action in a popup?

Hi,

Thanks for the comment.
But I am rendering the pdf file directly from the controller.
Then how can I do it? Can I open it using javascript ? or using any
another method  like send_data?


Thanks.
Sainaba
91a469d9f43a066babfd5531311d0fd1?d=identicon&s=25 Rath --- (rath)
on 2006-02-27 01:34
Does anyone know how to open a pdf file in a new window?
- Cannot read file myfile.pdf

Im trying this in my controller
# controller
def view_pdf
  send_data pdf.render, :filename => "myfile.pdf",:type =>
"application/pdf"
end

# application_helper.rb
def popup_pdf
  link_to "PDF",
    { :action => 'view_pdf' },
    :popup => ['new_window', 'height=300,width=600']
end

Any ideas?
91a469d9f43a066babfd5531311d0fd1?d=identicon&s=25 Rath --- (rath)
on 2006-02-27 01:54
Fix it, wrong folder :)

def view_pdf
  send_file "public/myfile.pdf"
end

Rath  wrote:
> Does anyone know how to open a pdf file in a new window?
> - Cannot read file myfile.pdf
>
> Im trying this in my controller
> # controller
> def view_pdf
>   send_data pdf.render, :filename => "myfile.pdf",:type =>
> "application/pdf"
> end
>
> # application_helper.rb
> def popup_pdf
>   link_to "PDF",
>     { :action => 'view_pdf' },
>     :popup => ['new_window', 'height=300,width=600']
> end
>
> Any ideas?
This topic is locked and can not be replied to.