From fe856dd21c07e8fdcc239580410bded340a93989 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 19 Dec 2013 22:18:26 +1030 Subject: [PATCH 5/5] pdftops: Only change paper size when different to previous size Previously this check was done in the code (removed in previous commit). Moving this check into the pdfSetupPaper macro preserves page independence. Bug 72312 --- poppler/PSOutputDev.cc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index f75a397..986ab7c 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -125,12 +125,32 @@ static const char *prolog[] = { " } ifelse", "} def", "/pdfSetupPaper {", - " 2 array astore", + " % Change paper size, but only if different from previous paper size otherwise", + " % duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size", + " % so we use the same when checking if the size changes.", " /setpagedevice where {", - " pop 2 dict begin", - " /PageSize exch def", - " /ImagingBBox null def", - " currentdict end setpagedevice", + " pop currentpagedevice", + " /PageSize known {", + " 2 copy", + " currentpagedevice /PageSize get aload pop", + " exch 4 1 roll", + " sub abs 5 gt", + " 3 1 roll", + " sub abs 5 gt", + " or", + " } {", + " true", + " } ifelse", + " {", + " 2 array astore", + " 2 dict begin", + " /PageSize exch def", + " /ImagingBBox null def", + " currentdict end", + " setpagedevice", + " } {", + " pop pop", + " } ifelse", " } {", " pop", " } ifelse", -- 1.8.3.2