Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Print Spooler API - how to copy/forward job to another printer (or extract data from it)?

233 views
Skip to first unread message

Bubba

unread,
Mar 17, 2015, 10:08:00 AM3/17/15
to
Greetings to all,

first of all, I apologize if this is off topic on this group, but I
couldn't find any more appropriate one!

This is my situation and I haven't been able to find solution so far - I
enumerate all printers on machine EnumPrinters() and open all handles with
OpenPrinter().

Afterwards, I keep pooling every 5 ms for new jobs by enumerating them
with EnumJobs() and if new job is found, I access details from JOB_INFO_2
structure. That gives me insight in which printer and some other details
from DEVMODE structure.

What I would actually like to do and I haven't found any solution so far
is the fact I would like to forward the job that happens on a certain
printer to another one without any user interaction.

In other words, if these are the printers:

Printer #1: SP C240DN DDST
Printer #2: HP LaserJet 400 M401 PCL 6
Printer #3: Canon Bubble-Jet BJC-6500

and someone prints anything on either printer #1 or printer #3, it would
automatically be printed out on #2.

Is such manipulation with printer jobs even possible? Can I extract data
from JOB_INFO_2 structure? Or get DOC_INFO_1 somehow and use
StartPagePrinter(), WritePrinter() and other functions to obtain data?

I am grateful in advance for any insight on this matter!

Best regards,

Bruno

--
"If you lie to the compiler,
it will get its revenge."
Henry Spencer
http://www.pci-z.com/

Geoff

unread,
Mar 18, 2015, 3:50:08 AM3/18/15
to
On 17 Mar 2015 14:07:57 GMT, Bubba <nick...@banelli.biz.invalid>
wrote:
So you want to, in essence, spy on printer queues and mirror those
queues to another printer without the users knowing?

Why do you think Windows security model should support this?

Bubba

unread,
Mar 18, 2015, 4:46:31 AM3/18/15
to
Geoff's log on stardate 18 ožu 2015

> So you want to, in essence, spy on printer queues and mirror those
> queues to another printer without the users knowing?

So I want to, in essence, do exactly what I have written above, only
locally, instead of having MPS for same purpose. What exactly is the point
of your malevolent, uncalled for and completely topic-irrelevant comment?

> Why do you think Windows security model should support this?

Because I firmly believe "Windows security model", whatever that
represents in this particular case, has nothing to do with it.

Essentially, as far as I understood from reading documentation, problem is
the fact there is no "file" to be printed per se (and, naturally, no path
to it) while working with printer jobs since you can print "Untitled
document" without even saving it - problem partially mitigated with
spooling but from Windows XP above, it is undocumented and sloppy to
"catch" spooler files. I am also concerned whether data type for certain
printers would be incompatible with others. However, since I don't see any
other way but to build DOC_INFO_x structure while sending data to printer,
one would presume that structure must be reachable somehow...

In addition, as far as I understood, there is something like that already
available, though I have never managed to make it work as it should.

http://www.pdfforge.org/pdfcmon

"It sits in the Windows print system and redirects print job information
into a file and calls our application. This is independent from the print
job format and works with PostScript, EMF, XPS and any other format
(RAW)."

R.Wieser

unread,
Mar 18, 2015, 4:48:21 AM3/18/15
to
Geoff,

> So you want to, in essence, spy on printer queues and mirror
> those queues to another printer without the users knowing?

Another, less "you're spying" reason could be that B&W printing is probably
cheapest on the Laserjet, and anyone mistakingly selecting one of the more
costly printers will, likely because of company policy, be automatically
retargetted.

In other words: not mirroring, but redirection. For a very sane reason.

Regards,
Rudy Wieser


-- Origional message:
Geoff <ge...@invalid.invalid> schreef in berichtnieuws
kbbigalt4quvb1aqu...@4ax.com...

Deanna Earley

unread,
Mar 18, 2015, 4:58:33 AM3/18/15
to
On 17/03/2015 14:07, Bubba wrote:
> What I would actually like to do and I haven't found any solution so far
> is the fact I would like to forward the job that happens on a certain
> printer to another one without any user interaction.
>
> In other words, if these are the printers:
>
> Printer #1: SP C240DN DDST
> Printer #2: HP LaserJet 400 M401 PCL 6
> Printer #3: Canon Bubble-Jet BJC-6500
>
> and someone prints anything on either printer #1 or printer #3, it would
> automatically be printed out on #2.

Given that the printing is done by the drivers and actual data will be different from each driver to the printer, I doubt this is possible.
I have no solid info to back that up though.

--
Deanna Earley (d...@earlsoft.co.uk, d...@doesnotcompute.co.uk)

(Replies direct to my email address will be printed, shredded then fed to the rats. Please reply to the group.)

Bubba

unread,
Mar 18, 2015, 7:09:17 AM3/18/15
to
R.Wieser's log on stardate 18 ožu 2015

> Another, less "you're spying" reason could be that B&W printing is
> probably cheapest on the Laserjet, and anyone mistakingly selecting
> one of the more costly printers will, likely because of company
> policy, be automatically retargetted.
>
> In other words: not mirroring, but redirection. For a very sane
> reason.

Given his tone, I wasn't really keen to explain details, but that's about
it; in addition, some users would like to keep PDF archive backed up, so
we can make sure that all document changes are always kept somewhere and
so on.

Bubba

unread,
Mar 18, 2015, 7:14:08 AM3/18/15
to
Deanna Earley's log on stardate 18 ožu 2015

> Given that the printing is done by the drivers and actual data will
> be different from each driver to the printer, I doubt this is
> possible. I have no solid info to back that up though.

Basically, you think that print job stored in JOB_INFO_n structure has
already been processed by printer drivers and there are no valuable data
in it?

Perhaps I should explore option of finding out if there is a possibility
to intercept or enumerate data when StartDocPrinter() is started...
0 new messages