]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In pdftopdf() fix cropping with long-edge-first
authorTill Kamppeter <till.kamppeter@gmail.com>
Sun, 27 Mar 2022 14:51:19 +0000 (16:51 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sun, 27 Mar 2022 14:51:19 +0000 (16:51 +0200)
If the printer takes the paper long-edge-first (lasers and inkjets
usually take it short-edge first, but roll-fed large-formats or label
printers also take long-edge-first) the cropping of the page image for
crop-to-fit (print-scaling=none) and fill (print-scaling=fill) by the
pdftopdf() filter function did not work correctly. This is fixed now.

Issue #454.

cupsfilters/pdftopdf/qpdf_pdftopdf_processor.cc

index f88bb272800f65d6e179b2240281d27cd007a44b..34b24334fd049b26fee90cedfb5a8f61d599486f 100644 (file)
@@ -194,7 +194,8 @@ Rotation QPDF_PDFTOPDF_PageHandle::crop(const PageRect &cropRect,Rotation orient
   double final_w,final_h;   //Width and height of cropped image.
 
   Rotation pageRot = getRotate(page);
-  if(pageRot==ROT_0||pageRot==ROT_180)
+  if (((pageRot == ROT_0 || pageRot == ROT_180) && pageWidth <= pageHeight) ||
+      ((pageRot == ROT_90 || pageRot == ROT_270) && pageWidth > pageHeight))
   {
     std::swap(pageHeight,pageWidth);
   }