Printing straight to default printer without showing print dialogue in CakePHP application

2,939 views
Skip to first unread message

blackFLINT

unread,
Feb 10, 2012, 5:43:43 AM2/10/12
to nodejs, sulley...@gmail.com
Hi,

Please I need some help and a friend suggested using node.js. The
issue at hand is that I am writing a cakePHP application that uses
jquery for validations. I'm now at a deadlock however. I want to print
straight to the default printer without popping up the printer dialog
on the clientside browser. Does anyone have any idea how node can
help.


Regards,
blackFLINT

Karl Tiedt

unread,
Feb 10, 2012, 9:54:13 AM2/10/12
to nod...@googlegroups.com

Call me crazy, but how are you expecting to access the printer from your server without the client having to approve anything?

Something on their side will have to talk to the printer and it isn't you're node application...

Chris Rhoden

unread,
Feb 10, 2012, 10:13:19 AM2/10/12
to nod...@googlegroups.com
Node is absolutely not going to help you on this front.

There is a way to tell the browser that you intend to print, but the user will need to confirm this request. You might be able to change the way that print confirmation works by using a Java applet and a TWAIN library, but this is not the right place to ask for help with that.

I should also say that this is a bad idea. Best of luck!

On Fri, Feb 10, 2012 at 9:54 AM, Karl Tiedt <kti...@gmail.com> wrote:

Call me crazy, but how are you expecting to access the printer from your server without the client having to approve anything?

Something on their side will have to talk to the printer and it isn't you're node application...

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
chrisrhoden

Kwaku Nuamah

unread,
Feb 10, 2012, 9:59:11 AM2/10/12
to nod...@googlegroups.com
Well the truth is it's page that will print a report of sorts if certain conditions are met. I'm looking to rewrite a vb.net application with php.
As I'm sure you know desktop applications can do this. Hence my search for a solution in a server-client web application.

Kwaku

On 10 February 2012 14:54, Karl Tiedt <kti...@gmail.com> wrote:

Call me crazy, but how are you expecting to access the printer from your server without the client having to approve anything?

Something on their side will have to talk to the printer and it isn't you're node application...

--

Karl Tiedt

unread,
Feb 10, 2012, 10:23:17 AM2/10/12
to nod...@googlegroups.com

Yes desktop apps can a access the printer connected to the computer running it... In this case it would be the browser doing the printing.... Not a remote Web server/application aka node

OldMster

unread,
Feb 10, 2012, 10:38:02 AM2/10/12
to nod...@googlegroups.com
The security sandbox that a browser enforces does not allow you to do anything to/with the users machine without their approval.  What you are trying to do will not be possible in a 'stock' browser with no plugins installed that enable this specific behavior.  Imagine going to a malicious web site and it have it start spewing paper out of your printer, or printing obscene or pornographic material 'automatically'.
Mark

Dan North

unread,
Feb 10, 2012, 12:06:56 PM2/10/12
to nod...@googlegroups.com
Maybe you're thinking about this replacement too literally. When a certain condition happens, which the server knows about, you want to send something to a printer that's associated with the user.

This print job doesn't need to be initiated by the user's browser, even though the current app works that way. The node server could connect straight to the printer (or a print service) and send it the report. Node is good at connecting to things.

(Of course you could have the printer details saved as a user preference).

From: Kwaku Nuamah <kwaku....@gmail.com>
Date: Fri, 10 Feb 2012 14:59:11 +0000
Subject: Re: [nodejs] Printing straight to default printer without showing print dialogue in CakePHP application

OldMster

unread,
Feb 10, 2012, 12:50:04 PM2/10/12
to nod...@googlegroups.com, tast...@gmail.com
That will work as long as the printer is a network shared printer, and is available to the server running node.  Since this is replacing a VB.net app, that is more likely, but not assured.
Mark

Kwaku Nuamah

unread,
Feb 10, 2012, 12:54:13 PM2/10/12
to nod...@googlegroups.com
Thanks for your input. And yes the printer is a network printer. However the default differs for every client pc. Another thing I need to mention is that this application is running on a common domain as the client pcs.

On 10 February 2012 17:50, OldMster <msi...@verizon.net> wrote:
That will work as long as the printer is a network shared printer, and is available to the server running node.  Since this is replacing a VB.net app, that is more likely, but not assured.
Mark

Jeroen Janssen

unread,
Feb 10, 2012, 9:16:36 PM2/10/12
to nodejs
Hi,

Here are a couple of thoughts on this:

*) the 'printer dialog' is there for a reason, one of them being able
to choose which printer to print to (i.e. if it is not the default),
but also to make settings.
I could have a black/white printer as default, but maybe I also
have a color printer somewhere. Should I change the default
printerdriver (in windows) if I want to print color with your
application?
Related to settings, this could be wanting to print duplex
(2sided), staple settings (1, 2, none, etc), maybe I want a 2up/4up
print, quality high/low, etc. depending on how someone wants their
output.
I dont think there is any way to skip the printer dialog from the
browser.
However, there are things you can do to make a webpage 'printer
friendly' (there are some css things you can do different for
information that you would like to be printable).

*) generate postscript (pdf or pcl depending on your printer
abilities) on the server side and just send ("lpr") it to the printer
(if it supports this).
this completely "skips" the (local) printerdriver altogether.
the downside of this that you might not be able to address specific
printer features (some things are standardized in postscript, but
depending on the printer features it could require a special 'ticket'
in front of the job). You would also need to know the hostname of the
printer from the server, so what happens if a new printer is
installed?

Hope this helps,

Jeroen Janssen

Isaac Schlueter

unread,
Feb 10, 2012, 11:24:34 PM2/10/12
to nod...@googlegroups.com
Yeah, even from a native application, I'd consider writing directly to
the printer without checking in with the operating system to be a
badly-behaved application. Even apps that try to be clever and
provide their own print dialog annoy me every time I have to print
something. (Of course, I'm usually already a little annoyed at having
to print something in the first place ;)

But from a web app, this is just pretty much exactly wrong. Let the
user have a print dialog. It's ok.

Skyler Brungardt

unread,
Feb 12, 2012, 11:29:07 PM2/12/12
to nod...@googlegroups.com
Agreed, it's good for the user experience to let them know when you're printing something (or doing most things) on their behalf. Print dialogs are good for this.

However, just to explore what I *think* is the thing you're trying to do, let's assume a few things about this _hypothetical_ server app you're talking about:

1. The user, for some reason, either already knows about and expects this print job, or will never see it or care about its existence.
2. You have a way to determine what user is triggering the report (perhaps with a username, login creds, or whatnot).
3. You can match the user to the printer(s) associated with them. JSON files might be a good, simple way to store this info.
4. The server running node has access to the same network/printers that the user triggering the report does.

If all of the above are true, you could use node to grab the printer name associated with the user triggering the report and have it execute a local print job to the same printer the user has as a "default" printer, provided that you kept the data store that has the key/value pair up to date (otherwise you'd be printing to an out-of-date "default" printer). You'd need to pass the user creds to the server, and have the printers installed on the server, obviously.

It's worth it, I think, to do some strong consideration about the end-user experience; simpler is almost always better, and don't make the user think.

I hope this helps point you in the right direction, and good luck!


-Skyler

Kwaku Nuamah

unread,
Feb 13, 2012, 3:55:58 AM2/13/12
to nod...@googlegroups.com
I thank you for all your help. I'm considering using java fx shell as a browser to accomplish this. Also yes this is a software that has user/password login creds. I'm building an application for my company with branches all over the place.
Reply all
Reply to author
Forward
0 new messages