From: Michael R Sweet Date: Tue, 27 Apr 2021 20:25:52 +0000 (-0400) Subject: Fix the job-pages-per-set value for duplex printing. X-Git-Tag: v2.4b1~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2c2591197f6481254c392d4aeb8df7b11c3b042;p=thirdparty%2Fcups.git Fix the job-pages-per-set value for duplex printing. --- diff --git a/CHANGES.md b/CHANGES.md index 267597d0eb..e52432b8ee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index be924ba0b4..343a39353d 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -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); } } }