]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
rastertopdf: Filter fails if no PCLm default resolution given by printer
authorTill Kamppeter <till.kamppeter@gmail.com>
Mon, 28 Mar 2022 20:57:21 +0000 (22:57 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Mon, 28 Mar 2022 20:57:21 +0000 (22:57 +0200)
In PCLm output mode the filter failed to generate PCLm if the printer
has no "pclm-source-resolution-default" IPP attribute (which gets
added to the PPD as "*cupsPclmSourceResolutionDefault"). This often
happens if there is only a single supported resolution. We take now
the first item of "pclm-source-resolution-supported" as default
resolution to make the PCLm output working in this
situation. Offending printers are the HP LaserJet M14-M17 printers

See also https://github.com/apple/cups/issues/6022

(manually backported from commit 65d6ffab4076d7d4d867cdb669f59fea1a25ca41)

NEWS
filter/rastertopdf.cpp

diff --git a/NEWS b/NEWS
index 0ee401de7a726244451e5bfac3f2a55471513476..ca704590f6fd98d36c99bcd1da6bfa2a7f32d5ea 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
 NEWS - OpenPrinting CUPS Filters v1.28.13 - 2022-03-27
 ------------------------------------------------------
 
+CHANGES IN V1.28.14
+
+       - rastertopdf: In PCLm output mode the filter failed to
+         generate PCLm if the printer has no
+         "pclm-source-resolution-default" IPP attribute.
+
 CHANGES IN V1.28.13
 
        - pdftopdf: Fix N-up printing when paper is taken
index e5c719ceae0c2817032029a2e68bab4c272c641f..ad5dd34c5393fb07dc0801419885b7d12684e006 100644 (file)
@@ -1434,20 +1434,32 @@ int main(int argc, char **argv)
         pdf.pclm_raster_back_side = attr->value;
       }
 
-      attr_name = (char *)"cupsPclmSourceResolutionDefault";
+      attr_name = (char *)"cupsPclmSourceResolutionSupported";
       if ((attr = ppdFindAttr(ppd, attr_name, NULL)) != NULL)
       {
         fprintf(stderr, "DEBUG: PPD PCLm attribute \"%s\" with value \"%s\"\n",
             attr_name, attr->value);
-        pdf.pclm_source_resolution_default = attr->value;
+        pdf.pclm_source_resolution_supported = split_strings(attr->value, ",");
       }
 
-      attr_name = (char *)"cupsPclmSourceResolutionSupported";
+      attr_name = (char *)"cupsPclmSourceResolutionDefault";
       if ((attr = ppdFindAttr(ppd, attr_name, NULL)) != NULL)
       {
         fprintf(stderr, "DEBUG: PPD PCLm attribute \"%s\" with value \"%s\"\n",
             attr_name, attr->value);
-        pdf.pclm_source_resolution_supported = split_strings(attr->value, ",");
+        pdf.pclm_source_resolution_default = attr->value;
+      }
+      else if (pdf.pclm_source_resolution_supported.size() > 0)
+      {
+       pdf.pclm_source_resolution_default =
+         pdf.pclm_source_resolution_supported[0];
+       fprintf(stderr, "DEBUG: PPD PCLm attribute \"%s\" missing, taking first item of \"cupsPclmSourceResolutionSupported\" as default resolution\n",
+               attr_name);
+      }
+      else
+      {
+       fprintf(stderr, "ERROR: PCLm output: PPD file does not contain printer resolution information for PCLm.\n");
+       return 1;
       }
 
       attr_name = (char *)"cupsPclmCompressionMethodPreferred";