--- poppler/PSOutputDev.cc~ 2013-12-16 11:43:07.031088704 +0100 +++ poppler/PSOutputDev.cc 2013-12-16 14:30:42.843357990 +0100 @@ -1493,10 +1493,10 @@ switch (mode) { case psModePSOrigPageSizes: paperMatch = gTrue; - prevWidth = 0; - prevHeight = 0; case psModePS: if (paperMatch) { + prevWidth = 0; + prevHeight = 0; for (i = 0; i < paperSizes->getLength(); ++i) { size = (PSOutPaperSize *)paperSizes->get(i); writePSFmt("%%{0:s} {1:t} {2:d} {3:d} 0 () ()\n", @@ -3657,24 +3674,21 @@ landscape ? "Landscape" : "Portrait"); writePS("%%BeginPageSetup\n"); 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("<> setpagedevice\n", - width, height); - prevWidth = width; - prevHeight = height; - } - } else { - if ((height != prevWidth) || (width != prevHeight)) { - writePSFmt("<> setpagedevice\n", - height, width); - prevWidth = height; - prevHeight = width; - } + // 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("{0:d} {1:d} pdfSetupPaper\n", + width, height); + prevWidth = width; + prevHeight = height; + } + } else { + if ((height != prevWidth) || (width != prevHeight)) { + writePSFmt("{0:d} {1:d} pdfSetupPaper\n", + height, width); + prevWidth = height; + prevHeight = width; } } }