Suggestions on how to print from node.js

7,580 views
Skip to first unread message

Tauren Mills

unread,
May 17, 2012, 11:51:12 PM5/17/12
to nod...@googlegroups.com
I'd like to build a print server that receives jobs over the network and can print them to an attached printer. We were thinking about utilizing websockets to notify the print server that a job is ready, so node came to mind. But it doesn't seem like node is the right tool for interfacing with a printer. If anyone has ideas on how to do this, I'd love to hear them.

I've been looking at projects such as node-qt and node-gui, but they don't seem to support any printing features yet.

Although we prefer to use linux or OSX for everything, these print servers would be installed onsite at client locations. Besides the specific printers we need to print to only have Windows drivers at this time, so we will definitely need this to run on Windows platforms. 

Thanks for your thoughts.

Tauren

Tim Caswell

unread,
May 18, 2012, 12:03:22 AM5/18/12
to nod...@googlegroups.com
Sounds like you'd have to write a C++ node addon that interfaces with the windows print API and expose it to node as a JavaScript API.  Then when you deploy, include this binary addon pre-compiled along with node and your server code.

I doubt node will be able to talk to the printer out of the box unless windows exposes them using some tcp API to local processes.


Tauren

--
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

mscdex

unread,
May 18, 2012, 12:13:15 AM5/18/12
to nodejs
On May 17, 11:51 pm, Tauren Mills <tau...@groovee.com> wrote:
> I'd like to build a print server that receives jobs over the network and
> can print them to an attached printer. We were thinking about utilizing
> websockets to notify the print server that a job is ready, so node came to
> mind. But it doesn't seem like node is the right tool for interfacing with
> a printer. If anyone has ideas on how to do this, I'd love to hear them.

Maybe I misunderstand the need, but why not just use something like
CUPS? If you need to have programmatic access to it, they at least
have an HTTP interface. Otherwise in the worst case you'd just need to
write some kind of binding to the CUPS API.

Tim Caswell

unread,
May 18, 2012, 12:19:19 AM5/18/12
to nod...@googlegroups.com
Is there a cups server for windows?  If there is then that may be an option.  But I thought it was only a client driver.

From the CUPS website:

The CUPS Driver for Windows downloads currently only includes 32-bit Windows drivers and must be combined with the Microsoft PostScript driver as described on the cupsaddsmb(8) man page. 64-bit Windows drivers are now available in the Subversion repository and will eventually become part of an updated CUPS Driver for Windows download.
Note:
Foomatic-based drivers do not work with Windows clients.

mscdex

unread,
May 18, 2012, 12:23:55 AM5/18/12
to nodejs
On May 18, 12:13 am, mscdex <msc...@gmail.com> wrote:
> Maybe I misunderstand the need, but why not just use something like
> CUPS? If you need to have programmatic access to it, they at least
> have an HTTP interface. Otherwise in the worst case you'd just need to
> write some kind of binding to the CUPS API.

Another option might be to spawn a process to lpr, etc.

Jeroen Janssen

unread,
May 18, 2012, 3:01:17 AM5/18/12
to nodejs
Hi,

Printing (on any platform) to a printer basically consists of 2 steps.

1) generate PDL (http://en.wikipedia.org/wiki/
Page_description_language)

On Windows for example this could be done by a printerdriver that
translates
GDI calls into postscript. The important thing to note here is that
the printerdriver
knows how to deal with finishing options (like stapling, booklet,
trimming). If you
generate PDL data without the 'official' printerdriver then a
customer might not
be able to use these finishing options.

If finishing options is not relevant to you then you might be able
to use a
generic printerdriver (i.e. PDFCreator is a generic printerdriver
on Windows that
generates PDF files).

Note that on Windows there are generic printer drivers available
that can be
customized by printer manufacturers (i.e. this does the heavy
lifting from GDI to
postscript or pcl). For more information on that, see also:
http://msdn.microsoft.com/en-us/library/ff560843(v=vs.85)

2) transfer PDL data to printer

This highly depends on the printer type, but typical transport
'mechanisms' are LPR/LPD,
Socket Printing, USB and (ofcourse) LPT.

The OS has support for these transport mechanisms (on Windows this
is called 'printer port'
and there is a "Standard TCP/IP Port" available that can print to
network based printers).


So looking at all this, I have a couple of questions:

1) Are the jobs that you receive already in "PDL" format?

2) How is the attached printer actually attached? (i.e. network based
or USB)

3) (as already mentioned somewhere else in this thread)
Have you looked at CUPS?

Best regards,

Jeroen Janssen

Tauren Mills

unread,
May 18, 2012, 3:22:21 AM5/18/12
to nod...@googlegroups.com
Lots of great information here which I will look into.

1. The jobs are not in currently PDL format. We'd like to keep things simple to start with and just print a JPG or PDF.

2. The printer will be attached locally via USB, although there are some networked and LPT printers out there too. To start with, USB printing is our first goal.

3. I have not looked at CUPS, but will look into it. Finding out possible solutions is exactly why I posted here.

Just to clarify, I will be printing to various plastic ID card printers. I'd like to simply generate a JPG or PDF file on the server, transfer it to the client, and somehow send it to the printer. We know how to do all of this except sending to printer.

Here is the first printer we want to support:

Windows SDK
http://www.zebra.com/cardpartner/zmotif.php

However, there are many other brands and models we wish to support, and eventually we'd like to be able to encode mag stripes, RFID, laminate, fold paper, stuff envelopes, etc. So learning how to create PDL jobs will probably be necessary.

Thanks again for the help and ideas,
Tauren



Jeroen Janssen

unread,
May 18, 2012, 4:14:36 AM5/18/12
to nodejs
On May 18, 9:22 am, Tauren Mills <tau...@groovee.com> wrote:
> Just to clarify, I will be printing to various plastic ID card printers.
> I'd like to simply generate a JPG or PDF file on the server, transfer it to
> the client, and somehow send it to the printer. We know how to do all of
> this except sending to printer.
>
> Here is the first printer we want to support:
>
> Windows Print Driver http://www.zebra.com/us/en/support-downloads/card/zxp-series-3.html
>
> Windows SDK http://www.zebra.com/cardpartner/zmotif.php
>
> However, there are many other brands and models we wish to support, and
> eventually we'd like to be able to encode mag stripes, RFID, laminate, fold
> paper, stuff envelopes, etc. So learning how to create PDL jobs will
> probably be necessary.

Ok, so it looks like you will need to use the SDK to actually print to
the printer (it also means you probably don't need to look at CUPS, if
I were you I would just focus on the Zebra provided SDK for now). I
think you will need to either make node.js bindings to the C++ SDK, or
develop an external (standalone) tool based on the Zebra SDK.

I guess this is going to depend on what your future ideas are. If you
are going to make bindings then are you going to make bindings for
every SDK for every such printer you want to support? If you are just
sending jpg files for now it might be easier to just make a
commandline tool (using the SDK) that prints a jpg file and call that
from node.

Also, since the SDK requires Windows it means that the printer server
is going to run on Windows right? (i.e. the physical printer is
connected to a Windows machine via USB)

Best regards,

Jeroen Janssen

Vladimir Bezugliy

unread,
Oct 30, 2013, 11:02:28 AM10/30/13
to nod...@googlegroups.com, tau...@groovee.com
Hello Tauren,

It would be interesting to hear what solution you choose.

Best regards, 
Vladimir Bezugliy

Julien Morvan

unread,
Aug 12, 2014, 8:14:50 AM8/12/14
to nod...@googlegroups.com, tau...@groovee.com
Hello,

I use node-printer


Maybe this can help if someone is looking for a solution.

Jawahar Venkatesh

unread,
Jan 30, 2016, 2:14:28 AM1/30/16
to nodejs, tau...@groovee.com
Hi,
 I have tried this, but got errors in the process. unable to succeed in it still.
 if you have any suggestions let me know.

Thanks,
Jawahar

boby rahmawan

unread,
Feb 3, 2016, 4:28:10 PM2/3/16
to nod...@googlegroups.com, tau...@groovee.com
can u show us the error?

You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/f7eac8fd-1fc9-4ed1-8945-96a9a62b760e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards. . . .


Boby Rahmawan

Reply all
Reply to author
Forward
0 new messages