cups/cups-str2348.patch

51 lines
1.6 KiB
Diff
Raw Normal View History

--- cups-1.2.10/pdftops/PSOutputDev.cxx.str2348 2007-02-05 20:25:50.000000000 +0000
+++ cups-1.2.10/pdftops/PSOutputDev.cxx 2007-05-09 13:20:13.000000000 +0100
@@ -1159,7 +1159,14 @@
}
// Tell CUPS pstops filter not to do its own rotation...
- writePSFmt("%%cupsRotation: %d\n", pageRotate);
+ int cups_rotate = 0;
+ int width = (int)ceil(mediaBox->x2 - mediaBox->x1);
+ int height = (int)ceil(mediaBox->y2 - mediaBox->y1);
+ int imgWidth = (int)ceil(cropBox->x2 - cropBox->x1);
+
+ if (width > height && width > imgWidth) cups_rotate = 90;
+
+ writePSFmt("%%cupsRotation: %d\n", cups_rotate);
writePSFmt("%%Producer: xpdf/pdftops %s\n", xpdfVersion);
xref->getDocInfo(&info);
@@ -2511,17 +2518,19 @@
landscape = gFalse;
} else {
rotate = (360 - state->getRotate()) % 360;
+
+ fprintf(stderr, "DEBUG: Page rotate=%d, width=%d, height=%d, imgWidth=%d, imgHeight=%d\n",
+ state->getRotate(), width, height, imgWidth, imgHeight);
+
if (rotate == 0 || rotate == 180) {
- if ((width > height && imgWidth < imgHeight) ||
- (height > width && imgHeight < imgWidth)) {
+ if (width > height && width > imgWidth) {
rotate += 90;
landscape = gTrue;
} else {
landscape = gFalse;
}
} else { // rotate == 90 || rotate == 270
- if ((width > height && imgWidth < imgHeight) ||
- (height > width && imgHeight < imgWidth)) {
+ if (height > width && height > imgWidth) {
rotate = 270 - rotate;
landscape = gTrue;
} else {
@@ -2529,6 +2538,7 @@
}
}
}
+
writePSFmt("%%%%PageOrientation: %s\n",
landscape ? "Landscape" : "Portrait");
writePS("pdfStartPage\n");