diff options
author | Till Kamppeter <till.kamppeter@gmail.com> | 2013-12-14 16:05:09 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2014-02-05 19:42:50 +1030 |
commit | fe49033c9bd2103c13d4eb59983e06fdcdd33a8d (patch) | |
tree | befcccc59d398b16afee7f159b7da164ee59d067 | |
parent | 31edf585e62f4e91b7b64295cc8b978ac466ce58 (diff) |
pdftops: ensure paper size takes into account rotation
Bug 72312
-rw-r--r-- | poppler/PSOutputDev.cc | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 623251f6..32be0a3d 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1432,6 +1432,7 @@ void PSOutputDev::writeHeader(int firstPage, int lastPage, switch (mode) { case psModePSOrigPageSizes: + paperMatch = gTrue; prevWidth = 0; prevHeight = 0; case psModePS: @@ -3550,34 +3551,6 @@ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { switch (mode) { case psModePSOrigPageSizes: - x1 = (int)floor(state->getX1()); - y1 = (int)floor(state->getY1()); - x2 = (int)ceil(state->getX2()); - y2 = (int)ceil(state->getY2()); - width = x2 - x1; - height = y2 - y1; - if (width > height) { - landscape = gTrue; - } else { - landscape = gFalse; - } - writePSFmt("%%PageBoundingBox: {0:d} {1:d} {2:d} {3:d}\n", x1, y1, x2 - x1, y2 - y1); - writePS("%%BeginPageSetup\n"); - writePSFmt("%%PageOrientation: {0:s}\n", - landscape ? "Landscape" : "Portrait"); - if ((width != prevWidth) || (height != prevHeight)) { - // Set page size only when it actually changes, as otherwise Duplex - // printing does not work - writePSFmt("<</PageSize [{0:d} {1:d}]>> setpagedevice\n", width, height); - prevWidth = width; - prevHeight = height; - } - writePS("pdfStartPage\n"); - writePSFmt("{0:d} {1:d} {2:d} {3:d} re W\n", x1, y1, x2 - x1, y2 - y1); - writePS("%%EndPageSetup\n"); - ++seqPage; - break; - case psModePS: // rotate, translate, and scale page imgWidth = imgURX - imgLLX; @@ -3620,6 +3593,25 @@ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { landscape ? "Landscape" : "Portrait"); if (paperMatch) { writePSFmt("{0:d} {1:d} pdfSetupPaper\n", imgURX, imgURY); + if (mode == psModePSOrigPageSizes) { + // Set page size only when it actually changes, as otherwise Duplex + // printing does not work + if (rotate == 0 || rotate == 180) { + if ((width != prevWidth) || (height != prevHeight)) { + writePSFmt("<</PageSize [{0:d} {1:d}]>> setpagedevice\n", + width, height); + prevWidth = width; + prevHeight = height; + } + } else { + if ((height != prevWidth) || (width != prevHeight)) { + writePSFmt("<</PageSize [{0:d} {1:d}]>> setpagedevice\n", + height, width); + prevWidth = height; + prevHeight = width; + } + } + } } writePS("pdfStartPage\n"); if (rotate == 0) { |