foo2zjs and CUPS page accounting
Date: July 15, 2007 08:47AM
Last week, I noticed that the "jobs" pages on CUPS admin always showed
"Unknown" for the number of pages printed to my HP1018; moreover, I checked
/var/log/cups/page_log and it was empty.
After some investigation, I found that CUPS depends on 'PAGE: n c' lines being
output to stderr by pstops or one of the filters that are called for each page
printed. Also, I found that when there's a PPD file configured for the printer,
and that PPD defines at least 1 filter for it (as is the case with the.PPD files
included with the foo2zjs package), the pstops program does NOT output the
'PAGE: n c' lines, and so the CUPS page accounting can't register the number of
pages being printed. I checked the source for other filters (e.g, rastertohp)
and found that they indeed do output the required 'PAGE: n c' lines.
From the above, I concluded that the problem is caused by foo2zjs not outputting
the 'PAGE: n c' lines to stderr, so I made the following patch to the current
(Thu Jul 12 19:31:54 2007 CDT) source tarball:
--- foo2zjs.c.orig 2007-05-07 21:36:55.000000000 -0300
+++ foo2zjs.c 2007-07-15 07:53:23.000000000 -0300
@@ -482,6 +482,9 @@
if (current->len != 20 )
error(1,"wrong BIH length\n");
+ /* output the necessary line for CUPS page accounting to work */
+ fprintf(stderr, "PAGE: %d %d\n", ++pageno, Copies);
/* startpage, jbig_bih, jbig_bid, jbig_end, endpage */
w = (((long) current->data[ 4] << 24)
| ((long) current->data[ 5] << 16)
@@ -535,7 +538,7 @@
if ((PageNum & 1) == 0 && EvenPages)
SeekMedia = ftell(EvenPages) - 4;
if (Model == MODEL_2300DL)
- item_uint32_write(ZJI_MINOLTA_PAGE_NUMBER, ++pageno, ofp);
+ item_uint32_write(ZJI_MINOLTA_PAGE_NUMBER, pageno, ofp);
I've tested it and now page accounting works perfectly, with no ill
side-effects (at least none that I can detect).
I'm posting that here in the hope that it helps other people with the same
problem, but I offer no guarantees other than the standard "it works for me".
I'm also submitting this patch to foo2zjs's author, if it's OK he will probably
incorporate it on a future version of the program.
PS: for the record, some details of my environment:
Ubuntu 7.04 Feisty with all updates applied
CUPS 1.2.8 (Ubuntu package cupsys 1.2.8-0ubuntu8)
Printer: HP Laserjet 1018
Edited 1 time(s). Last edit at 07/15/2007 08:53AM by durval.