]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libppd: Corrections for determining resolution in ppdFilterPDFToPS()
authorTill Kamppeter <till.kamppeter@gmail.com>
Sun, 28 Aug 2022 21:49:32 +0000 (23:49 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sun, 28 Aug 2022 21:49:32 +0000 (23:49 +0200)
If we have a PPD file we use ppdRasterInterpretPPD() to determine the
actual resolution of the current job. Only consider the resolution
invalid if both horizontal and vertical resolution are 100 dpi.

When getting resolution from PPD's "Resolution" option setting or
default resolution, set y resolution to x resolution if we have only
one number ("600dpi").

ppd/pdftops.c

index 323f8ddd587ed349514c9f02678ebc25d678fafe..e7e9321da4f40c6caa45e56497c0968c754cca47 100644 (file)
@@ -829,7 +829,8 @@ ppdFilterPDFToPS(int inputfd,         /* I - File descriptor input stream */
     ppdRasterInterpretPPD(&header, ppd, num_options, options, NULL);
     /* 100 dpi is default, this means that if we have 100 dpi here this
        method failed to find the printing resolution */
-    if (header.HWResolution[0] > 100 && header.HWResolution[1] > 100)
+    resolution[0] = '\0';
+    if (header.HWResolution[0] != 100 || header.HWResolution[1] != 100)
     {
       xres = header.HWResolution[0];
       yres = header.HWResolution[1];
@@ -838,11 +839,16 @@ ppdFilterPDFToPS(int inputfd,         /* I - File descriptor input stream */
       strncpy(resolution, choice->choice, sizeof(resolution) - 1);
     else if ((attr = ppdFindAttr(ppd,"DefaultResolution",NULL)) != NULL)
       strncpy(resolution, attr->value, sizeof(resolution) - 1);
-    resolution[sizeof(resolution)-1] = '\0';
-    if ((xres == 0) && (yres == 0) &&
-       ((numvalues = sscanf(resolution, "%dx%d", &xres, &yres)) <= 0))
-      if (log) log(ld, CF_LOGLEVEL_DEBUG,
-                  "ppdFilterPDFToPS: No resolution information found in the PPD file.");
+    resolution[sizeof(resolution) - 1] = '\0';
+    if (((xres == 100 && yres == 100) || xres <= 0 || yres <= 0))
+    {
+      if (resolution[0] &&
+         (numvalues = sscanf(resolution, "%dx%d", &xres, &yres)) == 1)
+       yres = xres;
+      if (numvalues <= 0 && log)
+       log(ld, CF_LOGLEVEL_DEBUG,
+           "ppdFilterPDFToPS: No resolution information found in the PPD file.");
+    }
   }
   else{
     cfRasterPrepareHeader(&header, data, CF_FILTER_OUT_FORMAT_CUPS_RASTER,