]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix the job-pages-per-set value for duplex printing.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 27 Apr 2021 20:25:52 +0000 (16:25 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 27 Apr 2021 20:25:52 +0000 (16:25 -0400)
CHANGES.md
cups/ppd-cache.c

index 267597d0ebdf719f3f348eb91ac55d4df8cb766e..e52432b8eef3ded28102a23e4f40ec03a555ede4 100644 (file)
@@ -38,6 +38,7 @@ CUPS v2.4rc1 (Pending)
 - Now use a 60 second timeout for reading USB backchannel data (Issue #160)
 - The USB backend now tries harder to find a serial number (Issue #170)
 - Fixed `@IF(name)` handling in `cupsd.conf` (Apple #5918)
+- Fixed `job-pages-per-set` value for duplex print jobs.
 - Documentation fixes (Issue #92, Issue #163, Issue #177)
 - Localization updates (Issue #123, Issue #129, Issue #134, Issue #146,
   Issue #164)
index be924ba0b43bac82eeb19aa332d2ab49678698eb..343a39353d8d5680a1bb66acb7cfe88c79398a6c 100644 (file)
@@ -79,8 +79,11 @@ _cupsConvertOptions(
   int          num_finishings = 0,     /* Number of finishing values */
                finishings[10];         /* Finishing enum values */
   ppd_choice_t *choice;                /* Marked choice */
-  int           finishings_copies = copies;
+  int           finishings_copies = copies,
                                         /* Number of copies for finishings */
+                job_pages = 0,         /* job-pages value */
+               number_up = 1;          /* number-up value */
+  const char   *value;                 /* Option value */
 
 
  /*
@@ -366,6 +369,22 @@ _cupsConvertOptions(
   * Map finishing options...
   */
 
+  if (copies != finishing_copies)
+  {
+    // Figure out the proper job-pages-per-set value...
+    if ((value = cupsGetOption("job-pages", num_options, options)) == NULL)
+      value = cupsGetOption("com.apple.print.PrintSettings.PMTotalBeginPages..n.", num_options, options);
+
+    if (value)
+      job_pages = atoi(value);
+
+    // When duplex printing, raster data will include an extra (blank) page to
+    // make the total number of pages even.  Make sure this is reflected in the
+    // page count...
+    if ((job_pages & 1) && (keyword = cupsGetOption("sides", num_options, options)) != NULL && strcmp(sides, "one-sided"))
+      job_pages ++;
+  }
+
   if ((finishing_template = cupsGetOption("cupsFinishingTemplate", num_options, options)) == NULL)
     finishing_template = cupsGetOption("finishing-template", num_options, options);
 
@@ -377,13 +396,13 @@ _cupsConvertOptions(
     ippAddCollection(request, IPP_TAG_JOB, "finishings-col", fin_col);
     ippDelete(fin_col);
 
-    if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
+    if (copies != finishings_copies && job_pages > 0)
     {
      /*
       * Send job-pages-per-set attribute to apply finishings correctly...
       */
 
-      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
+      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", job_pages);
     }
   }
   else
@@ -393,13 +412,13 @@ _cupsConvertOptions(
     {
       ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings", num_finishings, finishings);
 
-      if (copies != finishings_copies && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
+      if (copies != finishings_copies && job_pages > 0)
       {
        /*
        * Send job-pages-per-set attribute to apply finishings correctly...
        */
 
-       ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / finishings_copies);
+       ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", job_pages);
       }
     }
   }