]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Introduce print-as-raster as printer/job attribute 1282/head
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 10 Jun 2025 12:57:49 +0000 (14:57 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 10 Jun 2025 12:57:49 +0000 (14:57 +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 0e907d734ea93c93fce083fd2fad2a6d28d3eaea..8b6bb51a96d6163893274c941848a72bc1b73fe6 100644 (file)
@@ -298,6 +298,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 f3aa5e745c9352ba82a2ea5acf17688c653fb5aa..7b3e4483908a891bb2ff88888ace6a7df6f01093 100644 (file)
@@ -184,6 +184,9 @@ Prints the job in landscape (rotated 90 degrees clockwise).
 </p>
     <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>-o orientation-requested=6</strong><br>
 Prints the job in reverse portrait (rotated 180 degrees).
+</p>
+    <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>-o print-as-raster</strong><br>
+Prints the job as raster.
 </p>
     <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>-o print-quality=3</strong><br>
 </p>
index f11c27c230dd43ab48b0112c425ac4621e7d2884..26d7421ffa8742c2e15a444d4ee6b2031ac904e0 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 1748d1036baa989ac984bd0feaa85568cf300cd0..8691e2662a713a14da35b39e6f4e91987738f418 100644 (file)
@@ -1517,6 +1517,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_PTYPE_CLASS | CUPS_PTYPE_REMOTE);
   job->attrs   = con->request;
   job->dirty   = 1;
index 7b1ab093c80907ef3db23908269f7475f1164a08..4383c7743fff744a09667ff72885f66da0a5d001 100644 (file)
@@ -579,7 +579,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
@@ -596,9 +596,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));
@@ -5247,7 +5247,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 8562cac41623ac9e78ad188e5db3110532f03e38..a035fc659d6d276f568a6a74b2e2730032d41552 100644 (file)
@@ -76,7 +76,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 6b78e0d3253fc92d1e5af0a7d4fe02cf355e0fcb..0469734c26f35c5af6b68093f6fdc4583ce41c4c 100644 (file)
@@ -578,6 +578,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);