ghostscript/ghostscript-duplex.patch
2014-02-27 16:16:13 +00:00

67 lines
3.5 KiB
Diff

diff -up ghostscript-9.10/devices/vector/opdfread.h.duplex ghostscript-9.10/devices/vector/opdfread.h
--- ghostscript-9.10/devices/vector/opdfread.h.duplex 2013-08-30 11:37:28.000000000 +0100
+++ ghostscript-9.10/devices/vector/opdfread.h 2014-02-27 15:59:45.986847087 +0000
@@ -734,10 +734,27 @@ const char *opdfread_ps [] = {
"0 0}ifelse\n",
"round cvi 2 index round cvi eq\n",
"exch round cvi 3 index round cvi eq and{\n",
+"//PDFR_DEBUG{(PageSize matches request) == flush}if\n",
"pop pop}{\n",
+"/MediaRequested where {\n",
+"//PDFR_DEBUG{(MediaRequested is true, check against new request) == flush}if\n",
+"/MediaRequested get aload pop\n",
+"round cvi 2 index round cvi eq\n",
+"exch round cvi 3 index round cvi eq and\n",
+"{//PDFR_DEBUG{(MediaRequested same as current request, ignore) == flush}if pop pop false}\n",
+"{//PDFR_DEBUG{(MediaRequested different to current request) == flush}if true}ifelse\n",
+"}{\n",
+"//PDFR_DEBUG{(No MediaRequested yet) == flush}if\n",
+"true\n",
+"}ifelse\n",
+"{\n",
+"//PDFR_DEBUG{(Setting pagesize) == flush}if\n",
"2 array astore\n",
+"dup /MediaRequested exch def\n",
"<< exch /PageSize exch >> setpagedevice\n",
-"} ifelse\n",
+"/pagesave save def\n",
+"}if\n",
+"}ifelse\n",
"userdict/PDFR_InitialGS gstate put\n",
"setglobal\n",
"}if\n",
diff -up ghostscript-9.10/lib/opdfread.ps.duplex ghostscript-9.10/lib/opdfread.ps
--- ghostscript-9.10/lib/opdfread.ps.duplex 2013-08-30 11:37:28.000000000 +0100
+++ ghostscript-9.10/lib/opdfread.ps 2014-02-27 15:59:45.987847093 +0000
@@ -896,13 +896,27 @@ currentdict end readonly def
0 0 % dummy page size values if not known
}ifelse
% bw bh px0 py0 bw bh bool bw bh Width Height
- round cvi 2 index round cvi % bw bh px0 py0 bw bh bool bw bh Width bool
+ round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool
exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool
{ % Page Size unchanged, do not emit setpagedevice
pop pop % bw bh px0 py0 bw bh bool
} {
- 2 array astore % bw bh px0 py0 bw bh bool []
- << exch /PageSize exch >> setpagedevice % bw bh px0 py0 bw bh bool
+ /MediaRequested where {
+ % bw bh px0 py0 bw bh
+ /MediaRequested get aload pop % bw bh px0 py0 bw bh Width Height
+ round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool
+ exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool
+ {pop pop false} % We already requested this media size, so don't re-request
+ {true} ifelse % Media request different to last request
+ } {
+ true % No stored media request, so apply setpagedevice
+ } ifelse
+ {
+ 2 array astore % bw bh px0 py0 bw bh bool []
+ dup /MediaRequested exch def
+ << exch /PageSize exch >> setpagedevice % bw bh px0 py0 bw bh bool
+ /pagesave save def
+ } if
} ifelse
userdict /PDFR_InitialGS gstate put
setglobal % bw bh px0 py0 bw bh