If one turns off auto-rotating in the pdftopdf() filter function
(option "nopdfAutoRotate") the orientation of the input page on the
output sheet is manually controlled by the options
"orientation-requested" and "landscape".
The cropping of the pages (with "print-scaling=none") did not work
correctly with auto-rotating turned off. This commit fixes this.
Now all should work correctly as described here:
https://openprinting.github.io/cups/doc/options.html
https://wiki.debian.org/CUPSPdfToPdf
(manually backported from commit
f730a1f8c23b11e89e665aba5f77e8dd979db795)
CHANGES IN V1.28.14
+ - pdftopdf: Correct the output when suppressing auto-rotation
+ (option "nopdfAutoRotate"). Depending on the situation pages
+ got cropped in the wrong orientation or de-centered.
- pdftopdf: Correct the output when the
"orientation-requested" or the "landscape" option is
supplied. Output could be de-centered (Issue #456),
orientation = param.normal_landscape;
else
orientation = ROT_0;
- page->crop(param.page, orientation, param.xpos, param.ypos,
- !param.cropfit);
+ page->crop(param.page, orientation, param.orientation,
+ param.xpos, param.ypos,
+ !param.cropfit, param.autoRotate);
}
if (param.fillprint)
param.fitplot = true;
// fscale: inverse_scale (from nup, fitplot)
virtual void add_border_rect(const PageRect &rect,BorderType border,float fscale) =0;
// TODO?! add standalone crop(...) method (not only for subpages)
- virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale) =0;
+ virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate) =0;
virtual bool is_landscape(Rotation orientation) =0 ;
virtual void add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop=NULL) =0;
virtual void mirror() =0;
* Trim Box is used for trimming the page in required size.
* scale tells if we need to scale input file.
*/
-Rotation QPDF_PDFTOPDF_PageHandle::crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale)
+Rotation QPDF_PDFTOPDF_PageHandle::crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate)
{
page.assertInitialized();
Rotation save_rotate = getRotate(page);
double final_w,final_h; //Width and height of cropped image.
Rotation pageRot = getRotate(page);
- if (((pageRot == ROT_0 || pageRot == ROT_180) && pageWidth <= pageHeight) ||
- ((pageRot == ROT_90 || pageRot == ROT_270) && pageWidth > pageHeight))
+ if ((autorotate &&
+ (((pageRot == ROT_0 || pageRot == ROT_180) &&
+ pageWidth <= pageHeight) ||
+ ((pageRot == ROT_90 || pageRot == ROT_270) &&
+ pageWidth > pageHeight))) ||
+ (!autorotate &&
+ (param_orientation == ROT_90 || param_orientation == ROT_270)))
{
std::swap(pageHeight,pageWidth);
}
virtual void mirror();
virtual void rotate(Rotation rot);
virtual void add_label(const PageRect &rect, const std::string label);
- virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale);
+ virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate);
virtual bool is_landscape(Rotation orientation);
void debug(const PageRect &rect,float xpos,float ypos);
private: