michaelrsweet / pappl

PAPPL - Printer Application Framework
https://www.msweet.org/pappl
Apache License 2.0
309 stars 49 forks source link

Printing on custom page size does not work, tray with custom page size not accepted as default #120

Closed tillkamppeter closed 3 years ago

tillkamppeter commented 3 years ago

After adding custom page size support to the PostScript Printer Application I have set the page size of one tray to a custom size on the "Media" page and then selected this tray as default on "Printing Defaults". After that I have left the "Printing Defaults" page to get to another page of the web interface and clicked into "Printing Defaults" again, finding that the other tray (using one of the standard size) was selected as default. The log showed:

Unsupported media-default=custom_custom_5.5x11in_5.5x11in

I checked the code and found the problem. Here is the patch to fix it:

diff --git a/pappl/printer-driver.c b/pappl/printer-driver.c
index d5b37ec..4bf3acf 100644
--- a/pappl/printer-driver.c
+++ b/pappl/printer-driver.c
@@ -1212,8 +1212,8 @@ validate_defaults(

       if (pwg->length > max_length)
         max_length = pwg->length;
-      if (pwg->length > max_length)
-        max_length = pwg->length;
+      if (pwg->length < min_length)
+        min_length = pwg->length;
     }
   }

With this change custom page sizes work as intended.

michaelrsweet commented 3 years ago

[master 64d4b4d] Fix an issue with validation of custom media sizes (Issue #120)