OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.05k stars 187 forks source link

number-up applied twice with Apple clients #971

Closed dkosovic closed 1 month ago

dkosovic commented 4 months ago

Unfortunately, when the _cups mDNS subtype is used, no AirPrint queues get automatically generated for macOS clients, which then requires the print driver to be installed automatically through Apple Updates if available or they have to be preinstalled or manually installed.

Consequently, many sites with Macs drop advertising the _cups mDNS subtype to take advantage of automatically generated AirPrint queues, unfortunately number-up gets applied twice when the _cups mDNS subtype is not used.

I'm hoping something like the following patch could be applied to prevent number-up getting applied twice, I've tested it with macOS and iOS clients. I used the com.apple.print.totalPages..n. option just to determine it was an Apple client and only then exclude the listed options if _cups mDNS subtype is not being advertised. The excluded options are based on what cups-filters' pdftops excludes (not sure if all of the options should be excluded or not):

diff --git a/scheduler/job.c b/scheduler/job.c
index 49e4fa337..cb8fc01ac 100644
--- a/scheduler/job.c
+++ b/scheduler/job.c
@@ -4004,6 +4004,47 @@ get_options(cupsd_job_t *job,        /* I - Job */
      banner_page)
         continue;

+#ifdef HAVE_DNSSD
+      /*
+       * When calling a filter, we exclude the following options from its
+       * command line as the Apple client would have applied these options
+       * already if this CUPS server appears as a printer instead of a print
+       * server which occurs when the _cups dns-sd subtype is not used.
+       */
+      if ((!strcmp(attr->name, "crop-to-fit") ||
+           !strcmp(attr->name, "fill") ||
+           !strcmp(attr->name, "fitplot") ||
+           !strcmp(attr->name, "fit-to-page") ||
+           !strcmp(attr->name, "landscape") ||
+           !strcmp(attr->name, "orientation-requested") ||
+           !strcmp(attr->name, "brightness") ||
+           !strcmp(attr->name, "cupsEvenDuplex") ||
+           !strcmp(attr->name, "gamma") ||
+           !strcmp(attr->name, "hue") ||
+           !strcmp(attr->name, "ipp-attribute-fidelity") ||
+           !strcmp(attr->name, "MirrorPrint") ||
+           !strcmp(attr->name, "mirror") ||
+           !strcmp(attr->name, "multiple-document-handling") ||
+           !strcmp(attr->name, "natural-scaling") ||
+           !strcmp(attr->name, "number-up") ||
+           !strcmp(attr->name, "number-up-layout") ||
+           !strcmp(attr->name, "OutputOrder") ||
+           !strcmp(attr->name, "page-border") ||
+           !strcmp(attr->name, "page-bottom") ||
+           !strcmp(attr->name, "page-label") ||
+           !strcmp(attr->name, "page-left") ||
+           !strcmp(attr->name, "page-ranges") ||
+           !strcmp(attr->name, "page-right") ||
+           !strcmp(attr->name, "page-set") ||
+           !strcmp(attr->name, "page-top") ||
+           !strcmp(attr->name, "position") ||
+           !strcmp(attr->name, "saturation") ||
+           !strcmp(attr->name, "scaling")) &&
+          strstr(DNSSDSubTypes, "_cups") == NULL &&
+          ippFindAttribute(job->attrs, "com.apple.print.totalPages..n.", IPP_TAG_ZERO))
+        continue;
+#endif /* HAVE_DNSSD */
+
      /*
       * Otherwise add them to the list...
       */
csfjeff commented 3 months ago

This is an issue for us as well.

michaelrsweet commented 1 month ago

Unfortunately, this problem needs to be fixed at the macOS client side since they are sending number-up and other options.

If you don't use Mac-specific PPD files on the print server then the Apple client won't need any Mac drivers to be installed. At least that is a workaround until Apple fixes AirPrint -> CUPS support.