From bad72741aad21b17a3965673f3e7949a2fc7c256 Mon Sep 17 00:00:00 2001 From: Chris Liddell Date: Fri, 21 Aug 2020 18:50:55 +0100 Subject: PDF interp: Consolidate disabling of page handler device --- Resource/Init/pdf_main.ps | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index 6c1990d4b..5a5007391 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps @@ -278,6 +278,16 @@ systemdict begin } bind odef currentdict /runpdfstring .undef +/DisablePageHandlerDevice +{ + systemdict /FirstPage known + systemdict /LastPage known or + systemdict /Pagelist known or + { + <> setpagedevice + } if +} bind def + /runpdfbegin { % runpdfbegin - userdict begin % It turns out that the PDF interpreter uses memory more @@ -300,6 +310,8 @@ currentdict /runpdfstring .undef %% resources and needs this definition in place. <> setuserparams + //DisablePageHandlerDevice exec + 0 setobjectformat /Page# //null def /Page //null def @@ -311,8 +323,9 @@ currentdict /runpdfstring .undef /CumulativePageCount currentpagedevice /PageCount get def } bind executeonly def +currentdict /DisablePageHandlerDevice undef + /runpdfpagerange { % - runpdfpagerange - <> setpagedevice /PortfolioPage where { pop PortfolioPage cvi dup pdfpagecount add % a b+1 @@ -321,8 +334,8 @@ currentdict /runpdfstring .undef dup 3 index exch cvs pop % a b+1 /P (b+1) store 1 sub % a b - /FirstPage where { pop FirstPage <> setpagedevice} { 1 } ifelse - /LastPage where { pop LastPage <> setpagedevice} {2000000000} ifelse % a b fp lp + /FirstPage where { pop FirstPage} { 1 } ifelse + /LastPage where { pop LastPage} {2000000000} ifelse % a b fp lp 2 index 2 index lt { % b < fp 1e10 } { @@ -395,7 +408,6 @@ currentdict /runpdfstring .undef pop } forall - <> setpagedevice /PDFPageList pdfpagecount 1 add array def { (,) search { @@ -477,7 +489,6 @@ currentdict /runpdfstring .undef 1 pdfpagecount }{ /FirstPage where { - <> setpagedevice pop FirstPage dup pdfpagecount gt { (\nRequested FirstPage is greater than the number of pages in the file: ) print pdfpagecount = flush @@ -485,7 +496,7 @@ currentdict /runpdfstring .undef } { 1 } ifelse - /LastPage where {<> setpagedevice pop LastPage pdfpagecount .min } { pdfpagecount } ifelse + /LastPage where {pop LastPage pdfpagecount .min } { pdfpagecount } ifelse 1 index 1 index gt { ( No pages will be processed \(FirstPage > LastPage\).) = flush } { @@ -496,7 +507,6 @@ currentdict /runpdfstring .undef } ifelse } ifelse }ifelse - <> setpagedevice } bind executeonly def /dopdfpages { % firstpage# lastpage# dopdfpages - @@ -544,6 +554,7 @@ currentdict /runpdfstring .undef PDFTopSave restore end % userdict 2 vmreclaim % couldn't hurt + <> setpagedevice } bind executeonly def % Copy stream to an external temporary file and -- cgit v1.2.1