summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_main.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_main.ps322
1 files changed, 238 insertions, 84 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
index 7690bae0f92..d7933700f73 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2019 Artifex Software, Inc.
+% Copyright (C) 2001-2020 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -47,7 +47,7 @@ userdict /GS_PDF_ProcSet undef
% PDF 1.1 operators
/BX { /BXlevel BXlevel 1 add store } bind executeonly
/EX { /BXlevel BXlevel 1 sub store } bind executeonly
- /PS { cvx exec } bind executeonly
+ /PS { DOPS { cvx exec } { pop } ifelse } bind executeonly % PS disabled by default, as in pdf_draw.ps DoPS
% PDF 1.2 operators
/BMC {
/BMClevel BMClevel 1 add store
@@ -278,6 +278,16 @@ systemdict begin
} bind odef
currentdict /runpdfstring .undef
+/DisablePageHandlerDevice
+{
+ systemdict /FirstPage known
+ systemdict /LastPage known or
+ systemdict /Pagelist known or
+ {
+ <</DisablePageHandler //true>> setpagedevice
+ } if
+} bind def
+
/runpdfbegin { % <file> 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.
<</MaxOpStack -1>> 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 <firstpage#> <lastpage#>
-<</DisablePageHandler //true>> 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 <</DisablePageHandler //true>> setpagedevice} { 1 } ifelse
- /LastPage where { pop LastPage <</DisablePageHandler //true>> 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
- <</DisablePageHandler //true>> setpagedevice
/PDFPageList pdfpagecount 1 add array def
{
(,) search {
@@ -477,7 +489,6 @@ currentdict /runpdfstring .undef
1 pdfpagecount
}{
/FirstPage where {
- <</DisablePageHandler //true>> 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 {<</DisablePageHandler //true>> 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
} {
@@ -513,7 +524,12 @@ currentdict /runpdfstring .undef
{
dup /Page# exch store
QUIET not { (Page ) print dup //== exec flush } if
- pdfgetpage pdfshowpage
+ pdfgetpage
+ dup //null ne { pdfshowpage } {
+ ( **** Error: Page #) pdfformaterror Page# 10 string cvs pdfformaterror
+ ( not found.\n) pdfformaterror
+ /dopdfpages cvx /syntaxerror signalerror
+ } ifelse
}{
pop
}ifelse
@@ -538,6 +554,7 @@ currentdict /runpdfstring .undef
PDFTopSave restore
end % userdict
2 vmreclaim % couldn't hurt
+ <</DisablePageHandler //false>> setpagedevice
} bind executeonly def
% Copy stream to an external temporary file and
@@ -1879,7 +1896,7 @@ currentdict /xref-char-dict undef
parent_obj_get % not found -- check it's parent.
} ifelse
} {
- pop pop pop 0
+ pop pop 0
} ifelse
} bind executeonly def
@@ -2076,14 +2093,19 @@ currentdict /xref-char-dict undef
/pdffindpageref { % <int> pdffindpage <objref>
dup pdffindpage?
% Stack: index countleft noderef
- 1 index 1 ne { pop pop /pdffindpage cvx /rangecheck signalerror } if
- exch pop
- PageIndex 2 index 1 sub 65533 .min 2 index oforce put
- PageNumbers 1 index oforce 3 index dup 65534 le
- { put }
- { pop pop pop } % don't store more than 65534 pagenumbers
+ dup //null ne {
+ 1 index 1 ne { pop pop /pdffindpage cvx /rangecheck signalerror } if
+ exch pop
+ PageIndex 2 index 1 sub 65533 .min 2 index oforce put
+ PageNumbers 1 index oforce 3 index dup 65534 le
+ { put }
+ { pop pop pop } % don't store more than 65534 pagenumbers
+ ifelse
+ } {
+ exch pop % return the //null
+ }
ifelse
- exch pop
+ exch pop % pop the page number, return the object or null
} bind executeonly def
/pdffindpage { % <int> pdffindpage <pagedict>
pdffindpageref oforce
@@ -2339,8 +2361,20 @@ end readonly def
/get_media_box { % <pagedict> get_media_box <box> <bool>
/MediaBox pget {
- oforce_array //true
- } {
+ oforce_array
+ dup length 4 eq {
+ //true
+ }
+ {
+ pop
+ ( **** Error: Page has an invalid /MediaBox attribute. Using the current page size.\n)
+ pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ [ 0 0 currentpagedevice /PageSize get aload pop ]
+ //false
+ }ifelse
+ }
+ {
( **** Error: Page has no /MediaBox attribute. Using the current page size.\n)
pdfformaterror
( Output may be incorrect.\n) pdfformaterror
@@ -2493,9 +2527,26 @@ end readonly def
1
} {
1 index /UserUnit knownoget {
- PDFDEBUG { (Scaling due to UserUnit by ) print dup = flush } if
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop dup {
+ [ /UserUnit 4 -1 roll .pdfputparams pop pop 1 exch
+ } if
+ }{
+ //false
+ }ifelse
+
+ not {
+ PDFDEBUG { (Scaling due to UserUnit by ) print dup = flush } if
+ } if
} {
- 1
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop {
+ [ /UserUnit 1 .pdfputparams pop pop
+ } if
+ 1
+ }{
+ 1
+ } ifelse
} ifelse
} ifelse
} ifelse
@@ -2573,8 +2624,23 @@ currentdict /PDF2PS_matrix_key undef
% Set the page size.
//systemdict /NoUserUnit .knownget not { //false } if not {
3 index /UserUnit knownoget {
- dup 4 -1 roll mul 3 1 roll mul
- } if
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop dup {
+ [ /UserUnit 4 -1 roll .pdfputparams pop pop
+ } if
+ }{
+ //false
+ }ifelse
+ not {
+ dup 4 -1 roll mul 3 1 roll mul
+ } if
+ } {
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop {
+ [ /UserUnit 1 .pdfputparams pop pop
+ } if
+ }if
+ } ifelse
} if
} ifelse
2 array astore /PageSize exch def
@@ -2707,7 +2773,7 @@ currentdict /PDF2PS_matrix_key undef
dup /PDFusingtransparency exch def {
% If the current device isn't CMYK, or if it is a device that (currently) supports transparency
% we don't need the special handling of Overprint transparency, so disable the checking.
- currentpagedevice dup /Colors get 4 lt
+ currentpagedevice dup /Colors get 4 lt 1 index /SimulateOverprint get not or
exch /HaveTransparency .knownget not { //false } if or
% device needs special Oveprint handling
/setup_trans exch
@@ -2740,7 +2806,7 @@ currentdict /PDF2PS_matrix_key undef
.poppdf14devicefilter % NB: reset to DefaultQstate will also restore transfer function
/DefaultQstate qstate store % device has changed -- reset DefaultQstate
} {
- /setup_trans { pop } def % no-op this if the page doesn't use transparency
+ /setup_trans { pop pop } def % no-op this if the page doesn't use transparency
% NB: original will be restored from PDFsave
showpagecontents
} ifelse
@@ -2856,7 +2922,20 @@ currentdict /PDF2PS_matrix_key undef
% Draw the annotations
//systemdict /ShowAnnots .knownget not { //true } if {
/Annots knownoget {
- { oforce
+ dup type /arraytype eq {
+ {
+ /AnnotDrawCheck exch % marker to clean up stack on error
+ {oforce} stopped
+ {
+ ( **** Error: Unable to draw an annotation.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ count -1 0 { % make sure we don't go past the top of the stack
+ pop % remove the counter
+ /AnnotDrawCheck eq {exit} if % remove object and check if its the marker, exit if it is
+ } for
+ }
+ {
+ exch pop
dup //null ne {
.writepdfmarks
%%
@@ -2878,7 +2957,14 @@ currentdict /PDF2PS_matrix_key undef
} {
pop
} ifelse
+ } ifelse
} forall
+ }
+ {
+ ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ pop
+ } ifelse
} if
} if
//systemdict /ShowAcroForm .knownget { //true eq } { //false } ifelse {
@@ -3062,36 +3148,56 @@ currentdict /PDF2PS_matrix_key undef
/annotsusetransparency { % <page dict> annotsusetransparency <bool>
//false exch % Assume no transparency
/Annots knownoget { % Get Annots array
+ dup type /arraytype eq {
+ {
+ /AnnotTransparencyCheck exch % marker to clean up stack on error
+ {oforce} stopped
+ {
+ ( **** Error: Unable to check an annotation for use of transparency.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ count -1 0 { % make sure we don't go past the top of the stack
+ pop % remove the counter
+ /AnnotTransparencyCheck eq {exit} if % remove object and check if its the marker, exit if it is
+ } for
+ }
+ {
+ exch pop % remove the 'on error' marker
+ dup //null ne {
+ dup /Subtype knownoget {
+ /Highlight eq { % Highlight annotation is always implemented
+ pop pop //true exit % as transparency.
+ } if
+ } if
+ dup /AP knownoget { % Get appearance dict for the annoation
+ /N knownogetdict { % Get the /N (i.e. normal) appearance stream
+ 4 dict exch resourceusestransparency { pop pop //true exit } if
+ } if
+ } if % If AP dict known
+ dup /BM knownoget {
+ pop pop pop //true exit
+ } if
+ dup /CA knownoget {
+ 1 le {
+ pop pop //true exit
+ } if
+ } if
+ /ca knownoget {
+ 1 le {
+ pop //true exit
+ } if
+ } if
+ } {
+ pop
+ } ifelse
+ } ifelse
+ } forall % For all annots on the page
+ }
{
- oforce
- dup //null ne {
- dup /Subtype knownoget {
- /Highlight eq { % Highlight annotation is always implemented
- pop pop //true exit % as transparency.
- } if
- } if
- dup /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- 4 dict exch resourceusestransparency { pop pop //true exit } if
- } if
- } if % If AP dict known
- dup /BM knownoget {
- //true exit
- } if
- dup /CA knownoget {
- 1 le {
- pop pop //true exit
- } if
- } if
- /ca knownoget {
- 1 le {
- pop //true exit
- } if
- } if
- } {
- pop
- } ifelse
- } forall % For all annots on the page
+ ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ pop
+ }
+ ifelse
} if
} bind executeonly def
@@ -3208,17 +3314,24 @@ currentdict /PDF2PS_matrix_key undef
% <spotcolordict> <loopdict> <annotsarray>
% annotsspotcolors <spotcolordict> <loopdict>
/annotsspotcolors {
- { oforce
- dup //null ne {
- /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- resourcespotcolors
- } if % If normal appearance streamknown
- } if % If AP dict known
- } {
- pop
- } ifelse
- } forall
+ dup type /arraytype eq {
+ { oforce
+ dup //null ne {
+ /AP knownoget { % Get appearance dict for the annoation
+ /N knownogetdict { % Get the /N (i.e. normal) appearance stream
+ resourcespotcolors
+ } if % If normal appearance streamknown
+ } if % If AP dict known
+ } {
+ pop
+ } ifelse
+ } forall
+ }
+ {
+ ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ pop
+ } ifelse
} bind executeonly def
% Determine spot colors are used within a page. We are creating a dict to
@@ -3242,6 +3355,7 @@ currentdict /PDF2PS_matrix_key undef
{
/Parent knownoget
{
+ dup /Pages known not { pop exit } if % not a valid Page Tree ancestor
dup 4 1 roll
resourcespotcolors
3 -1 roll
@@ -3534,6 +3648,43 @@ currentdict /PDF2PS_matrix_key undef
} bind executeonly def
end % pdfdict
+
+
+systemdict /ALLOWPSTRANSPARENCY get
+{
+ /.setopacityalpha
+ {
+ /.setfillconstantalpha where
+ {
+ pop
+ ( **** WARNING: .setopacityalpha is deprecated (as of 9.53.0) and will be removed in a future release\n) print
+ ( **** See .setfillconstantalpha/.setalphaisshape for the improved solution\n) print flush
+ false .setalphaisshape
+ dup .setfillconstantalpha
+ .setstrokeconstantalpha
+ }
+ {
+ /.setopacityalpha /undefined cvx signalerror
+ } ifelse
+ } bind def
+
+ /.setshapealpha
+ {
+ /.setfillconstantalpha where
+ {
+ pop
+ ( **** WARNING: .setshapealpha is deprecated (as of 9.53.0) and will be removed in a future release.\n) print
+ ( **** See .setfillconstantalpha/.setalphaisshape for the improved solution\n) print flush
+ true .setalphaisshape
+ dup .setfillconstantalpha
+ .setstrokeconstantalpha
+ }
+ {
+ /.setshapealpha /undefined cvx signalerror
+ } ifelse
+ } bind def
+} if
+
.setglobal
%% This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
@@ -3545,24 +3696,27 @@ end % pdfdict
/.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
/.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
-/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.currentblendmode
-/.currentopacityalpha /.currentshapealpha /.currenttextknockout
-/.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup
-/.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x
-/.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha
-/.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
-/.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise
-/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize
-/.setdistillerparams
-
-% Used by our own test suite files
-%/.pushpdf14devicefilter % transparency-example.ps
-%/.poppdf14devicefilter % transparency-example.ps
-%/.setopacityalpha % transparency-example.ps
-%/.setshapealpha % transparency-example.ps
-%/.endtransparencygroup % transparency-example.ps
+/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.pushextendedgstate
+/.popextendedgstate
+
+/.pdfinkpath /.pdfFormName /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
+/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
+/.setPDFfontsize /.currentPDFfontsize /.setdistillerparams
% undefining these causes errors/incorrect output
-%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint
-%/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
+%/.settextrenderingmode
] systemdict .undefinternalnames
+
+% The following are split out allowing control via ALLOWPSTRANSPARENCY command line param
+% The examples/transparency_example.ps uses some of these (on the first line).
+[
+ /.pushpdf14devicefilter /.poppdf14devicefilter /.setstrokeconstantalpha /.setfillconstantalpha /.endtransparencygroup
+ /.currentblendmode /.currenttextknockout /.begintransparencytextgroup
+ /.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.begintransparencypagegroup
+ /.endtransparencymask /.image3x /.abortpdf14devicefilter /.setstrokeconstantalpha /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
+ % undefining these causes errors/incorrect output
+ %/.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint
+ %/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
+ %/.setSMask /.currentSMask
+
+] systemdict dup /ALLOWPSTRANSPARENCY get {pop pop}{.undefinternalnames}ifelse