Comment 0 for bug 126139

Revision history for this message
DurvalMenezes (durval) wrote :

Version information:
      Ubuntu 7.04 Feisty with all updates applied
      CUPS 1.2.8 (Ubuntu package cupsys 1.2.8-0ubuntu8)
      Printer: HP Laserjet 1018 connected directly to an USB 2.0 port

Problem description:
     The "jobs" pages on CUPS admin always show "Unknown" for the number of pages printed;
     moreover, I checked /var/log/cups/page_log and it was empty.

Investigation and solution:
    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 Ubuntu
     package sources (foo2zjs_20061224-0ubuntu3):

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-[
--- foo2zjs.c.orig-20070715 2006-12-07 11:24:31.000000000 -0200
+++ foo2zjs.c 2007-07-15 07:17:04.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)
@@ -528,7 +531,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);
 }

 void
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-]

    I've tested it and now page accounting works perfectly, with no ill
    side-effects (at least none that I can detect).

    I've also posted the above fix upstream (updated to the last upstream version),
    both to foo2zjs community forum at http://foo2zjs.rkkda.com/forum/read.php?8,488
   and directly to its author.

==Eof==