--- a/devices/vector/opdfread.h
+++ b/devices/vector/opdfread.h
@@ -734,10 +734,27 @@
 "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",
--- a/lib/opdfread.ps
+++ b/lib/opdfread.ps
@@ -896,13 +896,27 @@
       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
