Forum: Ruby on Rails Printing with rails

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
20b82a6b37e6570263d17044d7dcb37f?d=identicon&s=25 Jaikishan Jalan (Guest)
on 2008-12-06 23:12
(Received via mailing list)

I have a button which when clicks sends exam_id to server. The method
queries results of all the students who has appeared in this exam (No.
student > 30). I want to now print this data at client side. I am
how do I achieve this? I dont want to display this data at client
instead, I just want to show a progress bar that printing in progress
once I get all the data from server, I need to print it.

Any pointers to get started on this?

A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2008-12-06 23:25
(Received via mailing list)
This is not possible.

You don't tell the client to "print" something, you may write
javascript code to print the current page, but you can not print
something without sending it to the client (and asking the browser to
print it).

What you may do is try to hide the content in the page until a "print"
button is clicked, but the data has to be visible somewhere on the
page to be printed.

The javascript code to tell the browser to print is "window.print()".

Maurício Linhares (pt-br) |
10f7e00c1c5c60e2173995eb16f4ffc7?d=identicon&s=25 pepe (Guest)
on 2008-12-07 15:55
(Received via mailing list)
Maybe what you could do is to generate the data to be printed in a
document that the user could download, then you send a page with a
button to download it as a file that then they could print, but I
guess this defeats the purpose of 'automating' the printing of the


On Dec 6, 5:25 pm, "Maurício Linhares" <>
20b82a6b37e6570263d17044d7dcb37f?d=identicon&s=25 Jaikishan Jalan (Guest)
on 2008-12-07 16:00
(Received via mailing list)
Here is what I did - something similar to what Mauricio said. I made a
link_to_remote and when user clicks on it, it updates a div
with the data from the server. Using :complete attribute of
I call a javascript function which then creates a window taking data
the hidden div and then print the window via window.print() command.

It is working fine and giving me exactly what I wanted. Thanks for your

On Sun, Dec 7, 2008 at 8:24 PM, pepe <> wrote:

> wrote:
> >
> > > I have a button which when clicks sends exam_id to server. The method
> > > Any pointers to get started on this?
> >
> > > --
> > > Thanks,
> > > Jaikishan
> >

This topic is locked and can not be replied to.