Forum: Ruby on Rails AJAX automatic print to specific printer??

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.
4f02bcc434ddf5ee37cbce421ee51d2f?d=identicon&s=25 Sean Clark (Guest)
on 2006-04-12 18:20
Is it possible to print directly to an XP Pro default printer without
having to go through an intermediate dialog?  The clients are XP Pro
with IE. The printer is accessed directly through the network, but could
easily be setup as a Windows shared printer if that helps us out.  I've
seen where I can use window.print but the user still has to click OK.  I
would like to avoid any clicks at all for this particular page.

The application only runs on our LAN and users would like this part
automated since they are printing 100 times a day to the same printer
from the RoR app.  Automating the print function would save 300-400
clicks a day.

I would prefer to do this through JavaScript, but could result to CGI
for messy solution.  CGI would require me to have printing configured on
Linux which I'm trying to avoid.  JavaScript solution is also more
flexible long term.

thanks for your help,
Sean
0a5d6fa912dda67f9b81017fbd9a81f2?d=identicon&s=25 Shane Sherman (Guest)
on 2006-04-12 18:25
(Received via mailing list)
you're always going to have to go through the windows print dialog.
There's
no way around that, especially from a web application. you're restricted
by
the print functionality built into the browser.
4f02bcc434ddf5ee37cbce421ee51d2f?d=identicon&s=25 Sean Clark (Guest)
on 2006-04-12 18:43
Thanks, Shane.  That's a bummer.

for an ugly hack, is it possible to have RoR fork out and return the
HTML to the browser by also print the resulting HTML directly to the
network printer?  Does anyone have experience with linux web server to
HP network printers (or Windows print server)?

If the answer is a book, then I probably don't what to travel that dark
road.  We're talking about saving 1 measily click or keypress.
A0ed1bbfe42f4f87e6db0a16706246e2?d=identicon&s=25 Michael Greenly (mgreenly)
on 2006-04-12 19:34
Sean Clark wrote:
> Thanks, Shane.  That's a bummer.
>
> for an ugly hack, is it possible to have RoR fork out and return the
> HTML to the browser by also print the resulting HTML directly to the
> network printer?  Does anyone have experience with linux web server to
> HP network printers (or Windows print server)?
>
> If the answer is a book, then I probably don't what to travel that dark
> road.  We're talking about saving 1 measily click or keypress.

I have almost no knowledge about it about this may help...

http://raa.ruby-lang.org/project/ruby-cups/
http://www.cups.org/

It seems perfectly reasonable that you should be able to print to most
network printers this way.
A6b74fef495a52a7d868534e10024091?d=identicon&s=25 Sean Clark (smc7000)
on 2006-04-12 20:52
Thanks, Michael.  That's definitely my dark road.  I'm going to try and
get away with just using the onLoad window.print stuff.  If the users
get pitchforks out, then I'll look into the CUPs stuff. Thanks again.
41d82e6fb3cea1a8bcbe604b9410e303?d=identicon&s=25 Maximilian Schöfmann (Guest)
on 2006-05-10 12:37
(Received via mailing list)
Hi Sean,
> Is it possible to print directly to an XP Pro default printer without
> having to go through an intermediate dialog?  The clients are XP Pro
> with IE.
I assume that this is an intranet application and that the clients can
add this application to the "Trusted Sites" in IE (otherwise they will
get an ActiveX warning).
If thats the case, it is possible:

For IE, you have to add some javascript to the page your want to print
(found in a forum post some months ago):
<script language="JavaScript">
function printWithoutDialog() {
    self.focus();
    var OLECMDID_PRINT = 6;
    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
    var OLECMDEXECOPT_PROMPTUSER = 1;
    var WebBrowser ='<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 ' +
        'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    document.body.insertAdjacentHTML'beforeEnd',WebBrowser);
    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
    WebBrowser1.outerHTML =''
}
</script>


For Firefox, there's even a simpler solution if you have the possibility
to alter the prefs of the clients (I've done this for a kiosk-mode
application):
In your firefox, browse to "about:config" and right click to add a new
*boolean* value named "always_print_silent" (true). Done.

Both solutions will print to the default printer of the system.
In FF, you can change the printer with the "print_printer" value.

HTH,
Max
Cebc9541fbfe66e8bdb49c0d3713a3aa?d=identicon&s=25 William Fernando (numerouno)
on 2008-01-19 16:30
> For Firefox, there's even a simpler solution if you have the possibility
> to alter the prefs of the clients (I've done this for a kiosk-mode
> application):
> In your firefox, browse to "about:config" and right click to add a new
> *boolean* value named "always_print_silent" (true). Done.
>
> Both solutions will print to the default printer of the system.
> In FF, you can change the printer with the "print_printer" value.
>
> HTH,
> Max

por favor me aclaran este post sobre imprimir sobre Firefox, que no lo
entiendo y tengo la necesidad de imprimir directamente a la impresora
por default, sin que se habilite la pantalla de impresion.

gracias
Aaa01cead25315295d1bb0aebf21e6dc?d=identicon&s=25 kopf1988 (Guest)
on 2008-01-19 17:29
(Received via mailing list)
Creo que no es possible, por que mal websites queire imprimir mal
cosas.

Lo siento, mi espanol es muy mal. Otros personas aqui probablament no
habla espanol.

-Ryan

On Jan 19, 9:30 am, William Fernando <rails-mailing-l...@andreas-
This topic is locked and can not be replied to.