Print Server / Printer Accounting

Simo Sorce simo.sorce at
Thu Jul 20 07:25:52 GMT 2000

Samuel Greenfeld wrote:
>    Postscript documents that follow Adobe's conventions should contain "%%Page:" once per page to be printed (without the quotes).  Microsoft products seem to follow this.   However, no one says everyone must follow this.   You can have a perfectly legal postscript document without these markers.   I myself need to do PCL and PS counting, but I myself have run into problems, especially since PCL seems to use ^L for both graphics and denoting pages (I do not know any PCL myself - this was just me studying what was in various print jobs).   PCL 6 is even more of a nightmare than PCL 5 to understand - it encodes text in binary form (Unicode or UTF-8, I suspect).

PCL is really more difficult to understand than PS but your assertion
that Adobe always set the "%%Pages:" tag is unfortunately not always
I have a set of script, that samba launch instead of lpr, to make
acounting and this involves PS testing (I've installed Adobe PS printer
drivers on all the clients).
In the first I managed to only check "%%Pages" field and fortunately
logging what's going.
Well after some time I noticed some users claimed to have printed less
than reported and I found through logs that not all the files had
"%%Pages" field; don't know why and do not have time to investigate
further. I still trust the "%%Pages" field when I found it, but if it is
not there I managed to check the number of Pages by filtering a copy of
the file through mpage -v that sends me back the number of pages

>    If you have a bidirectional link to your printers (often available around port 9100 on HP's JetDirect Boxes), and have printers that keep track of page counts internally, you might be able to query the printer before and after each print job for the number of pages it has printed.   Subtract the two (or let a utility do it) and you have the number of pages printed.   Any decent departmental printer should support some method to do this (either by Hewlett Packard's PJL language or in Postscript itself).
>    The way I've done this is one many people probably would not like - I replaced my lpd with the one from the LPRng (lpr next-generation) project.   This is because a print filter capable of doing this method of accounting, ifhp, is designed alongside this particular lpd project.   These are not likely to disappear soon - LPRng has been around since 1988, and some significant places (such as MIT) supposively use it.
>    Lprng supports using accounting filters and many other tricks that a standard lpd can not do.   Ifhp can recognize various types of input, and use a converter if needed.   Ifhp also has a printer database of what can do what; tell it your model if it knows it, and you're basically set.   And best of all; Samba *does* know how to use lprng for printing.   I really should clarify and note that the ifhp/lprng combo only logs users and the number of pages they have printed; you still need to write some code to parse the print log they generate to account for what has been made.
>    Granted, like any page count method, this is not perfect.   The case where two servers spool for the same printer comes to mind.   When you have cheap supervisors that buy little desktop lasers that count pages but do not seem to be queriable, this might also be a problem.   But for anyone with at least the equivalent of an HP 4000 (and probably less), this is one route you can go that does not care what protocol is used for the print job.   (And if anyone can get a page count out of the parallel port of a HP 1100 printer, please let me know privately.)

Yes all you said is true, but those supervisors that buy cheap lasers or
even InkJet printers are more than you expect (and bugget is often a
I have an HP DJ1600 to do accounting on for students and it has not an
internal counter!
I've also read many papers on printers and HP printers in particular and
ways to foul accounting through consulting printer are many.
One is to switch off printer before th job ends, this will reset
counters on many laserjets. Just print a white last page ....

>    LPRng and ifhp can be found at .   See their respective HOWTOs for the basics, and how samba can fit in.   The GNU and "Artistic" Licenses apply, although commercial support and licensing is available as well.
> ---
> >>> Schlomo Schapiro <schapiro at> 07/19/00 10:56AM >>>
> Hi,
> actually counting PS pages is not so simple because counting the ShowPage
> command is not enough, especially in cases where people print multiple
> pages in one.
> Schlomo

Simo Sorce - Integrazione Sistemi Unix/Windows - Politecnico di Milano
E-mail: simo.sorce at 02 2399 2425 - 02 2399 2451
Be happy, use Linux!

More information about the samba-ntdom mailing list