]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Introduce print-as-raster as printer/job attribute
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 8 Jul 2025 13:26:19 +0000 (15:26 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 8 Jul 2025 13:26:19 +0000 (15:26 +0200)
Some printers do not take kindly newer PDF versions which results in
omitting font characters in the printout. Such jobs print fine as a
raster, however retrying as raster depends on benevolence of the printer
firmware what it counts as an unrecoverable printing error.

In the past, we preferred raster over PDF in cups-filters, causing other
issues like with finishings, or solutions like generating PCLm PPD were
mentioned, however it would require a way how to define for which models
it should be used, and take of such database.

Thus introducing print-as-raster job attribute, which makes the job
to be printed as raster, and print-as-raster-default printer attributes,
which makes any job coming into the printer object to be printed as raster.

Internally it uses similar mechanism as raster retry, which was adjusted
to match both use cases now.

cups/encode.c
doc/help/man-lp.html
man/lp.1
scheduler/ipp.c
scheduler/job.c
scheduler/job.h
scheduler/printers.c

index 25ec8f23f39fb9731bf6f36275fc0a6523bde7eb..5f6a9b517dee7f353af5591a0f6258dfd6542d2f 100644 (file)
@@ -300,6 +300,8 @@ static const _ipp_option_t ipp_options[] =
   { 0, "ppi-default",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 0, "prettyprint",          IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
   { 0, "prettyprint-default",  IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "print-as-raster",      IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "print-as-raster-default", IPP_TAG_BOOLEAN,     IPP_TAG_PRINTER },
   { 0, "print-color-mode",     IPP_TAG_KEYWORD,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "print-color-mode-default", IPP_TAG_KEYWORD,    IPP_TAG_PRINTER },
index 00002be6dcd855ce5fe845583478d2be8a5636f6..fe1260039fe13b93a4861e59d8e463e8155de310 100644 (file)
@@ -155,6 +155,8 @@ The "name" can be "classified", "confidential", "secret", "standard", "topsecret
 <dd style="margin-left: 5.0em">Prints the job in landscape (rotated 90 degrees clockwise).
 <dt><b>-o orientation-requested=6</b>
 <dd style="margin-left: 5.0em">Prints the job in reverse portrait (rotated 180 degrees).
+<dt><b>-o print-as-raster</b>
+<dd style="margin-left: 5.0em">Prints the job as raster.
 <dt><b>-o print-quality=3</b>
 <dd style="margin-left: 5.0em"><dt><b>-o print-quality=4</b>
 <dd style="margin-left: 5.0em"><dt><b>-o print-quality=5</b>
index d22358c6af62b2391380d6e506d98b9ac711a98e..15179280efea579c74ed10ca4ad55cef74af804a 100644 (file)
--- a/man/lp.1
+++ b/man/lp.1
@@ -180,6 +180,9 @@ Prints the job in landscape (rotated 90 degrees clockwise).
 \fB\-o orientation\-requested=6\fR
 Prints the job in reverse portrait (rotated 180 degrees).
 .TP 5
+\fB\-o print-as-raster\fR
+Prints the job as raster.
+.TP 5
 \fB\-o print\-quality=3\fR
 .TP 5
 \fB\-o print\-quality=4\fR
index 8b01ba16a6fa5d53a5b37502c5d4b65748995479..3bf015708d646d91526e7b12a17af597aa3ef2ab 100644 (file)
@@ -1524,6 +1524,9 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
     return (NULL);
   }
 
+  if (ippGetBoolean(ippFindAttribute(con->request, "print-as-raster", IPP_TAG_BOOLEAN), 0))
+    job->print_as_raster = 1;
+
   job->dtype   = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
   job->attrs   = con->request;
   job->dirty   = 1;
index 11579875968047ca3b44cd2c3fc0044b8c4eead5..58c7df462a79418e82630d5c7ab64408bcb3b957 100644 (file)
@@ -583,7 +583,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
 
     _cupsRWLockWrite(&MimeDatabase->lock);
 
-    if (job->retry_as_raster)
+    if (job->print_as_raster)
     {
      /*
       * Need to figure out whether the printer supports image/pwg-raster or
@@ -600,9 +600,9 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
       }
 
       if (dst)
-        cupsdLogJob(job, CUPSD_LOG_DEBUG, "Retrying job as \"%s\".", strchr(dst->type, '/') + 1);
+       cupsdLogJob(job, CUPSD_LOG_DEBUG, "%s job as \"%s\".", job->print_as_raster > 0 ? "Printing" : "Retrying", strchr(dst->type, '/') + 1);
       else
-        cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to retry job using a supported raster format.");
+       cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to print job using a supported raster format.");
     }
 
     filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], (size_t)fileinfo.st_size, dst, &(job->cost));
@@ -5220,7 +5220,7 @@ update_job(cupsd_job_t *job)              /* I - Job to check */
       cupsdLogJob(job, CUPSD_LOG_DEBUG, "JOBSTATE: %s", message);
 
       if (!strcmp(message, "cups-retry-as-raster"))
-        job->retry_as_raster = 1;
+        job->print_as_raster = -1;
       else
         ippSetString(job->attrs, &job->reasons, 0, message);
     }
index 619353d1bb50e7408ea0d055dfe9ed6913b9586d..b4820861b8bd1d645f567c7b4260bbf5dc66788c 100644 (file)
@@ -75,7 +75,8 @@ struct cupsd_job_s                    /**** Job request ****/
   int                  status;         /* Status code from filters */
   int                  tries;          /* Number of tries for this job */
   int                  completed;      /* cups-waiting-for-job-completed seen */
-  int                  retry_as_raster;/* Need to retry the job as raster */
+  int                  print_as_raster;
+                                       /* Need to print the job as raster */
   char                 *auth_env[3],   /* AUTH_xxx environment variables,
                                          * if any */
                        *auth_uid;      /* AUTH_UID environment variable */
index c84312f4d1ac1562bf93fe0425260224182b4340..24951068226b1408490375fcd3fb92bd26f43bff 100644 (file)
@@ -564,6 +564,9 @@ cupsdCreateCommonData(void)
   /* pdl-override-supported */
   ippAddString(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pdl-override-supported", NULL, "attempted");
 
+  /* print-as-raster-supported */
+  ippAddBoolean(CommonData, IPP_TAG_PRINTER, "print-as-raster-supported", 1);
+
   /* print-scaling-supported */
   ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-scaling-supported", sizeof(print_scaling) / sizeof(print_scaling[0]), NULL, print_scaling);