Hpps and page logging

Asked by Konstantin KABASSANOV

Hi,

There are some (very) old posts complaining about lacks of cups PAGE logging messages with hpps.
As workaround, somebody patched pdftopdf binary in cups, but this supposes that the upstream filter is pdftopdf, and there is nothing for other upstream ps filter.

Is there any evolution from your side?

Thanks.

Question information

Language:
English Edit question
Status:
Expired
For:
HPLIP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Santhosh Manchikanti (santhosh.m) said :
#1

Hi Konstantin,

Can you please more elaborate the query?

Regards,
Santhosh

Revision history for this message
Konstantin KABASSANOV (kabassanov) said :
#2

Hi Santhosh,

When a printer job uses pstops and hpps, nothing is logged out in /var/log/cups/page_log.

Debugging cups give the following chain:

   D [07/Jul/2018:18:22:59 +0200] [Job 284] 3 filters for job:
   D [07/Jul/2018:18:22:59 +0200] [Job 284] pstops (application/postscript to application/vnd.cups-postscript, cost 66)
   D [07/Jul/2018:18:22:59 +0200] [Job 284] hpps (application/vnd.cups-postscript to printer/test2/application/vnd.cups-postscript, cost 0)
   D [07/Jul/2018:18:22:59 +0200] [Job 284] - (printer/test2/application/vnd.cups-postscript to printer/test2, cost 0)

On the other hand when a printer job uses pdftopdf, there is a specific code in this binary that logs the printed page instead of hpps filter:

   D [07/Jul/2018:18:15:32 +0200] [Job 283] bannertopdf (application/vnd.cups-pdf-banner to application/pdf, cost 32)
   D [07/Jul/2018:18:15:32 +0200] [Job 283] pdftopdf (application/pdf to application/vnd.cups-pdf, cost 66)
   D [07/Jul/2018:18:15:32 +0200] [Job 283] pdftops (application/vnd.cups-pdf to application/vnd.cups-postscript, cost 100)
   D [07/Jul/2018:18:15:32 +0200] [Job 283] hpps (application/vnd.cups-postscript to printer/test2/application/vnd.cups-postscript, cost 0)
   D [07/Jul/2018:18:15:32 +0200] [Job 283] - (printer/test2/application/vnd.cups-postscript to printer/test2, cost 0)

In cups-filters-1.20.3/filter/pdftopdf/pdftopdf.cc, checkFeature function says:

// CUPS standard is that the last filter (not the backend, usually the
  // printer driver) does page logging in the /var/log/cups/page_log file
  // by outputting "PAGE: <# of current page> <# of copies>" to stderr.

And there is a piece of code for the hpps case:

} else if (!strcasecmp(lastfilter, "hpps")) {
            // hpps is last filter, hpps is part of HPLIP and it is a bug that
            // it does not do the page logging.
            param.page_logging = 1;

I think the best solution should be that hpps logs correctly and would like to know if there are plans to do it.

Thanks.

Revision history for this message
Konstantin KABASSANOV (kabassanov) said :
#3

I was thinking about something like this in hppsfilter.c (sorry line numbers are shifted due to other patches):

@@ -889,9 +895,29 @@ int main (int argc, char **argv)
          hpwrite("@PJL ENTER LANGUAGE=POSTSCRIPT\x0a", strlen("@PJL ENTER LANGUAGE=POSTSCRIPT\x0a"));
     }
     unsigned int numBytes = 0;
+ unsigned int pageCount = 0;
+ unsigned int numCopies = 0;
+ char NbCopies[MAX_BUFFER] = {0};
+
+
     while ( (numBytes = cupsFileGetLine(fp_input, line, sizeof(line))) > 0)
+ {
+ // Sometimes it is an argument, sometimes it is in the page content
+ if (!strncmp(line, "%%BeginNonPPDFeature: NumCopies", strlen("%%BeginNonPPDFeature: NumCopies"))) {
+ // Line is not defined by \n at the end, so need to take one line substring
+ strncpy(NbCopies,
+ line+strlen("%%BeginNonPPDFeature: NumCopies")+1,
+ strchr(line,'\n')-line-strlen("%%BeginNonPPDFeature: NumCopies")-2);
+ numCopies=atoi(NbCopies);
+ }
+ // Counting pages
+ if (!strncmp(line, "%%Page:", 7))
+ {
+ pageCount++;
+ fprintf(stderr, "PAGE: %d %d\n", pageCount,numCopies?numCopies:atoi(argv[4]) );
+ }
         hpwrite (line, numBytes);
-
+ }

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.