cups-filters/SOURCES/0001-pdftopdf-Fixed-printin...

50 lines
2.1 KiB
Diff

From a07a43f885a4a7186310639b214c499e09e453c5 Mon Sep 17 00:00:00 2001
From: Till Kamppeter <till.kamppeter@gmail.com>
Date: Tue, 13 Nov 2018 13:04:59 +0100
Subject: [PATCH] pdftopdf: Fixed printing multiple copies on driverless IPP
printers.
---
NEWS | 4 ++++
filter/pdftopdf/pdftopdf.cc | 24 +++++++++++++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/filter/pdftopdf/pdftopdf.cc b/filter/pdftopdf/pdftopdf.cc
index f474f08c6..880b664fd 100644
--- a/filter/pdftopdf/pdftopdf.cc
+++ b/filter/pdftopdf/pdftopdf.cc
@@ -783,11 +783,25 @@ void calculate(ppd_file_t *ppd,ProcessingParameters &param) // {{{
} else if ((ppd)&&(!ppd->manual_copies)) { // hw copy generation available
param.deviceCopies=param.numCopies;
if (param.collate) { // collate requested by user
- // check collate device, with current/final(!) ppd settings
- param.deviceCollate=printerWillCollate(ppd);
- if (!param.deviceCollate) {
- // printer can't hw collate -> we must copy collated in sw
- param.deviceCopies=1;
+ // Check output format (FINAL_CONTENT_TYPE env variable) whether it is
+ // of a driverless IPP printer (PDF, Apple Raster, PWG Raster, PCLm).
+ // These printers do always hardware collate if they do hardware copies.
+ // https://github.com/apple/cups/issues/5433
+ char *final_content_type = getenv("FINAL_CONTENT_TYPE");
+ if (final_content_type &&
+ (strcasestr(final_content_type, "/pdf") ||
+ strcasestr(final_content_type, "/vnd.cups-pdf") ||
+ strcasestr(final_content_type, "/pwg-raster") ||
+ strcasestr(final_content_type, "/urf") ||
+ strcasestr(final_content_type, "/PCLm"))) {
+ param.deviceCollate = true;
+ } else {
+ // check collate device, with current/final(!) ppd settings
+ param.deviceCollate=printerWillCollate(ppd);
+ if (!param.deviceCollate) {
+ // printer can't hw collate -> we must copy collated in sw
+ param.deviceCopies=1;
+ }
}
} // else: printer copies w/o collate and takes care of duplex/evenDuplex
} else { // sw copies
--
2.43.0