]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
pdftopdf: Add 2% tolerance for input size larger than output page
authorTill Kamppeter <till.kamppeter@gmail.com>
Sat, 5 Feb 2022 19:22:10 +0000 (16:22 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sat, 5 Feb 2022 19:22:10 +0000 (16:22 -0300)
When "print-scaling=auto" or "print-scaling=auto-fit" is used, the
input pages are scaled when they do not fit into the output page
size. Often input ad out page sizes are supposed to be equal, for
example both A4, but rounding errors could make the input considered
larger and unnecessarily scaled.

Therefore we add 2% of tolerance before considering an input page too
large.

(manually backported commit e541dc698f38aaa522f99e23b57c695da2981c29)

NEWS
filter/pdftopdf/pdftopdf_processor.cc

diff --git a/NEWS b/NEWS
index 55e7d828b3d84c56fda25e2fa6ae801fe3cae5b1..98a391a53fd96ad86f2b195e367ab0a8229def5d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,12 @@ CHANGES IN V1.28.12
          bottom or left != right) and for input files containing
          pages with different sizes and/or orientations. Fixes
          backported from 2.x branch.
+       - pdftopdf: Add 2% tolerance for input size larger than output
+         page when "print-scaling=auto" or "print-scaling=auto-fit"
+         is used and too large input pages should be scaled, fitting
+         documents not. This prevents a random-looking behavior if
+         input and output page size seem to be equal, but in reality
+         there are slight dependencies between size dimensions.
 
 CHANGES IN V1.28.11
 
index e297a246e97707a997cdd56096eeb4d1f651eea6..28643163f1d59780b91dfb27103a535fa2111734 100644 (file)
@@ -195,8 +195,8 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
     for (int i = 0; i < (int)pages.size(); i ++)
     {
       PageRect r = pages[i]->getRect();
-      int w = r.width;
-      int h = r.height;
+      int w = r.width * 100 / 102; // 2% of tolerance
+      int h = r.height * 100 / 102;
       if ((w > param.page.width || h > param.page.height) &&
          (h > param.page.width || w > param.page.height))
       {