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.ps216
1 files changed, 145 insertions, 71 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
index 00da47a4871..5305ea6132a 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-2018 Artifex Software, Inc.
+% Copyright (C) 2001-2019 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -18,8 +18,9 @@
/.setlanguagelevel where { pop 2 .setlanguagelevel } if
.currentglobal //true .setglobal
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
pdfdict begin
+/GS_PDF_ProcSet dup load def % keep in pdfdict to hide it
+userdict /GS_PDF_ProcSet undef
% Patch in an obsolete variable used by some third-party software.
/#? //false def
@@ -165,7 +166,7 @@ pdfdict begin
% WantsPageLabels means that pagelabels will be passed
% using .pdfpagelabels and not using pdfmarks
/WantsPageLabels /GetDeviceParam .special_op
- {pop pop false}{true} ifelse
+ {pop pop //false}{//true} ifelse
%% This is truly ugly.....
%% GSView 5 redefines pdfmark and processes it itself. However if it gets
@@ -175,11 +176,11 @@ pdfdict begin
%% try not to break it. We happen to know that GSView 5 installs a GSview
%% dictionary in userdict, so this test simply ensures we don't emit PAGELABEL
%% pdfmarks if that dictioanry is present.
- userdict /GSview known {pop false} if
+ userdict /GSview known {pop //false} if
} bind executeonly
% generate pagelabel pdfmark
/dopagelabel { % -- dopagelabel --
- << /S null /P () /O 0 >> begin
+ << /S //null /P () /O 0 >> begin
wantpagelabelmarks {
Trailer /Root knownoget {
oforce /PageLabels knownoget {
@@ -304,14 +305,14 @@ currentdict /runpdfstring .undef
/Page //null def
/DSCPageCount 0 def
/PDFSave //null def
- GS_PDF_ProcSet begin
- pdfdict begin
+ //pdfdict /GS_PDF_ProcSet get begin
+ //pdfdict begin
pdfopen begin
/CumulativePageCount currentpagedevice /PageCount get def
} bind executeonly def
/runpdfpagerange { % - runpdfpagerange <firstpage#> <lastpage#>
-<</DisablePageHandler true>> setpagedevice
+<</DisablePageHandler //true>> setpagedevice
/PortfolioPage where {
pop
PortfolioPage cvi dup pdfpagecount add % a b+1
@@ -320,8 +321,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 <</DisablePageHandler //true>> setpagedevice} { 1 } ifelse
+ /LastPage where { pop LastPage <</DisablePageHandler //true>> setpagedevice} {2000000000} ifelse % a b fp lp
2 index 2 index lt { % b < fp
1e10
} {
@@ -394,7 +395,7 @@ currentdict /runpdfstring .undef
pop
}
forall
- <</DisablePageHandler true>> setpagedevice
+ <</DisablePageHandler //true>> setpagedevice
/PDFPageList pdfpagecount 1 add array def
{
(,) search {
@@ -476,7 +477,7 @@ currentdict /runpdfstring .undef
1 pdfpagecount
}{
/FirstPage where {
- <</DisablePageHandler true>> setpagedevice
+ <</DisablePageHandler //true>> setpagedevice
pop FirstPage dup pdfpagecount gt {
(\nRequested FirstPage is greater than the number of pages in the file: ) print
pdfpagecount = flush
@@ -484,7 +485,7 @@ currentdict /runpdfstring .undef
} {
1
} ifelse
- /LastPage where {<</DisablePageHandler true>> setpagedevice pop LastPage pdfpagecount .min } { pdfpagecount } ifelse
+ /LastPage where {<</DisablePageHandler //true>> setpagedevice pop LastPage pdfpagecount .min } { pdfpagecount } ifelse
1 index 1 index gt {
( No pages will be processed \(FirstPage > LastPage\).) = flush
} {
@@ -507,7 +508,7 @@ currentdict /runpdfstring .undef
/PDFPageList where {
pop dup PDFPageList exch get 1 eq
}
- {true} ifelse
+ {//true} ifelse
{
dup /Page# exch store
@@ -624,7 +625,7 @@ currentdict /runpdfstring .undef
%% copied to a temporary file) and store it in pdfdict. We will use this for
%% hashing fonts to detect if fonts with the same name are from different files.
%%
- dup currentglobal exch true setglobal .getfilename exch setglobal /InputPDFFileName exch pdfdict 3 1 roll .forceput
+ dup currentglobal exch //true setglobal .getfilename exch setglobal /InputPDFFileName exch //pdfdict 3 1 roll .forceput
//runpdfbegin exec
//pdf_collection_files exec
@@ -757,7 +758,7 @@ pdfdict begin
% Bug #696454
PDFfile fileposition
/dictlevelcount 0 def
- /TrailerSizeError false def
+ /TrailerSizeError //false def
/TrailerSize 0 def
{
@@ -788,7 +789,7 @@ pdfdict begin
TrailerSize growPDFobjects
PDFfile exch setfileposition
0 % Initialize xref table error counter
- false % Have we seen at least one section entry in this xref ? Bug #694342
+ //false % Have we seen at least one section entry in this xref ? Bug #694342
{ PDFfile token pop % first object # or trailer
dup /trailer eq {
%% check to see if we have seen at least an empty section for this xref
@@ -822,9 +823,9 @@ pdfdict begin
2 copy add
TrailerSize gt {
TrailerSizeError not {
- /TrailerSizeError true def
+ /TrailerSizeError //true def
PDFSTOPONERROR not {
- (**** Warning: Discovered more enties in xref than declared in trailer /Size\n) pdfformatwarning
+ (**** Warning: Discovered more entries in xref than declared in trailer /Size\n) pdfformatwarning
} {
/readorigxref cvx /rangecheckerror signalerror
} ifelse
@@ -879,7 +880,7 @@ pdfdict begin
1 add % increment object number
} repeat
pop % pop <obj #>
- true % We have seen at least one entry in an xref section Bug #694342
+ //true % We have seen at least one entry in an xref section Bug #694342
} loop
0 ne {
( **** Warning: length of some xref entries is not equal to 20 bytes.\n)
@@ -1114,7 +1115,7 @@ currentdict /xref-char-dict undef
% Copy bookmarks (outline) to the output.
Trailer /Root knownoget {
/Outlines knownoget {
- /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{true}ifelse
+ /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{//true}ifelse
{
dup /First known {
100 dict exch %% dictionary for detecting circular references
@@ -1166,17 +1167,28 @@ currentdict /xref-char-dict undef
Trailer /Info {knownoget} stopped {
( **** Error: Unable to read Info dictionary from Trailer, Info will not be preserved.\n) pdfformaterror
count pdfemptycount sub {pop} repeat
+ /emitProducer where {/emitProducer //false put} if
}
{
{
- mark exch
- { /Author /Creator /Title /Subject /Keywords
- % /Producer is Ghostscript; /CreationDate is now; /ModDate is also now.
- } {
- 2 copy knownoget { 3 -1 roll } { pop } ifelse
- } forall
- pop
- dup mark ne { {/DOCINFO pdfmark} stopped {cleartomark} if } { pop } ifelse
+ %
+ % Bug #700820, if the Info dictionary isn't a dictionary, then don't try to use it....
+ %
+ dup type /dicttype eq {
+ mark exch
+ { /Author /Creator /Title /Subject /Keywords
+ % /Producer is Ghostscript; /CreationDate is now; /ModDate is also now.
+ } {
+ 2 copy knownoget { 3 -1 roll } { pop } ifelse
+ } forall
+ pop
+ dup mark ne { {/DOCINFO pdfmark} stopped {cleartomark} if } { pop } ifelse
+ }{
+ pop
+ ( **** Error: The Info dictionary is not a dictionary, Info will not be preserved.\n) pdfformaterror
+ count pdfemptycount sub {pop} repeat
+ /emitProducer where {/emitProducer //false put} if
+ } ifelse
} if
} ifelse
} if
@@ -1359,7 +1371,7 @@ currentdict /xref-char-dict undef
} if
} if
} ifelse
- } .internalstopped
+ } //.internalstopped exec
{ //true } if % If we stop then we need to rebuild
% Stack: <filesize> <obj num> <need rebuild flag>
{
@@ -1390,7 +1402,7 @@ currentdict /xref-char-dict undef
} bind executeonly def
/pdfopenfile { % <file> pdfopenfile <dict>
- pdfdict readonly pop % can't do it any earlier than this
+ //pdfdict readonly pop % can't do it any earlier than this
32 dict begin
/LocalResources 0 dict def
/DefaultQstate //null def % establish binding
@@ -1401,8 +1413,8 @@ currentdict /xref-char-dict undef
currentpagedevice /OutputFile known {
currentpagedevice /OutputFile get (%d) search {
pop pop pop
- /NO_PDFMARK_OUTLINES true def
- /NO_PDFMARK_DESTS true def
+ /NO_PDFMARK_OUTLINES //true def
+ /NO_PDFMARK_DESTS //true def
} {
pop
}ifelse
@@ -1413,10 +1425,11 @@ currentdict /xref-char-dict undef
cvlit /PDFfile exch def
/PDFsource PDFfile def
/Repaired //false def
+ /emitProducer //true def
/RepairedAnError //false def
/StreamRunAborted //false def
/NeedAppearances //false def
- /ICCProfileNError false def
+ /ICCProfileNError //false def
currentglobal //true .setglobal globaldict begin
/UndefProcList 0 dict def
end .setglobal
@@ -1450,15 +1463,15 @@ currentdict /xref-char-dict undef
/Trailer << >> def % Initialize to an emptry dict.
{initPDFobjects findxref readxref}
PDFSTOPONERROR not {
- .internalstopped {
+ //.internalstopped exec {
recover_xref_data % Read failed. Attempt to recover xref data.
search_trailer % Search for the primary trailer
- false % search_trailer sets up /Trailer, so don't run the code to do that...
+ //false % search_trailer sets up /Trailer, so don't run the code to do that...
} {
- true
+ //true
} ifelse
} {
- exec true
+ exec //true
} ifelse
{
@@ -1509,7 +1522,7 @@ currentdict /xref-char-dict undef
{ readxref }
PDFSTOPONERROR not {
- .internalstopped {
+ //.internalstopped exec {
recover_xref_data % Read failed. Attempt to recover xref data.
/PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references
exit % Exit loop since recover gets all obj data.
@@ -1561,18 +1574,18 @@ currentdict /xref-char-dict undef
<<
/EODCount 2 index bytesavailable %% fix data length at underlying bytes
/EODString () %% make sure filter passes that many bytes, no EOD
- /CloseSource false %% Be sure, tell the filter not to close the source file
+ /CloseSource //false %% Be sure, tell the filter not to close the source file
>>
/SubFileDecode filter dup %% -filter- -filter-
token { %% -filter- <any> true | false
%% token returned a value
exch %% <any> filter
closefile %% <any>
- true %% <any> true
+ //true %% <any> true
}{
%% token didn't find a value
closefile %% -
- false %% false
+ //false %% false
} ifelse
} {
token
@@ -1649,11 +1662,19 @@ currentdict /xref-char-dict undef
} odef
/printProducer {
- Trailer /Info { knownoget_safe } stopped { pop pop //false } if {
- /Producer knownoget not { //null } if
+ Trailer /Info { knownoget_safe } stopped { pop pop //false } if
+
+ {
+ /emitProducer where {/emitProducer get}{//true} ifelse
+ {
+ /Producer knownoget not { //null } if
+ }{
+ pop //null
+ } ifelse
} {
//null
} ifelse
+
dup //null eq {
pop
} {
@@ -1841,25 +1862,51 @@ currentdict /xref-char-dict undef
ifelse
} bind executeonly def
-/obj_get {
+/parent_obj_get { % /ResourceName pagedict /ObjType LocalResourceDir
+ /ParentResources .knownget {
+ dup 2 index .knownget {
+ % Found ObjType directory
+ 4 index .knownget {
+ 0 get 5 1 roll pop pop pop pop
+ } {
+ parent_obj_get % not found -- check it's parent.
+ } ifelse
+ } {
+ parent_obj_get % not found -- check it's parent.
+ } ifelse
+ } {
+ pop pop pop 0
+ } ifelse
+} bind executeonly def
+
+/obj_get { % /ResourceName pagedict /ObjType obj_get
+ % success: /ResourceName objnumber
+ % fail: /ResourceName /ResourceName 0
LocalResources 1 index knownoget {
- dup 4 index known {
- 3 index get
- 0 get 4 1 roll pop pop pop
- } if
+ dup 4 index .knownget {
+ 0 get 5 1 roll pop pop pop pop
+ } {
+ pop pop pop 0
+ } ifelse
} {
+ % Not in LocalResources. Try Page Resources.
1 index /Resources pget {
1 index knownoget {
dup 4 index known {
3 index get
0 get 4 1 roll pop pop pop
}{
- pop pop pop 0
+ % Not in Page Resources, recursively try ParentResources as a last resort
+ pop % page Resources
+ LocalResources parent_obj_get
}ifelse
}{
- pop pop pop 0
+ % No Page Resources, recursively try ParentResources as a last resort
+ pop % page Resources
+ LocalResources parent_obj_get
} ifelse
} {
+ % No Page Resources, recursively try ParentResources as a last resort
pop pop pop 0
}ifelse
}ifelse
@@ -2642,7 +2689,7 @@ currentdict /PDF2PS_matrix_key undef
% If the current device isn't CMYK, or if it is a HighLevelDevice (pdfwrite) we
% don't need the special handling of Overprint transparency, so disable the checking.
currentpagedevice dup /Colors get 4 lt exch /HighLevelDevice known or {
- /checkOPtrans { pop false } def % NB: original will be restored from PDFsave
+ /checkOPtrans { pop //false } def % NB: original will be restored from PDFsave
} if
% Show the page within a PDF 1.4 device filter.
0 .pushpdf14devicefilter {
@@ -2655,7 +2702,7 @@ currentdict /PDF2PS_matrix_key undef
} {
1 index get_media_box pop /MediaBox exch
} ifelse
- oforce_elems normrect_elems fix_empty_rect_elems 4 array astore .beginformgroup
+ oforce_elems normrect_elems fix_empty_rect_elems 4 array astore .beginpagegroup
showpagecontents
.endtransparencygroup
} {
@@ -2671,7 +2718,7 @@ currentdict /PDF2PS_matrix_key undef
.poppdf14devicefilter % NB: reset to DefaultQstate will also restore transfer function
/DefaultQstate qstate store % device has changed -- reset DefaultQstate
} {
- /checkOPtrans { pop false } def % no-op the check if the page doesn't use transparency
+ /checkOPtrans { pop //false } def % no-op the check if the page doesn't use transparency
% NB: original will be restored from PDFsave
showpagecontents
} ifelse
@@ -2691,24 +2738,24 @@ currentdict /PDF2PS_matrix_key undef
StreamRunAborted not {
(\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
- pdfdict /.Qqwarning_issued .knownget
+ //pdfdict /.Qqwarning_issued .knownget
{
{
pop
}
{
- currentglobal pdfdict gcheck .setglobal
- pdfdict /.Qqwarning_issued //true .forceput
+ currentglobal //pdfdict gcheck .setglobal
+ //pdfdict /.Qqwarning_issued //true .forceput
.setglobal
pdfformaterror
- } ifelse
+ } executeonly ifelse
}
{
- currentglobal pdfdict gcheck .setglobal
- pdfdict /.Qqwarning_issued //true .forceput
+ currentglobal //pdfdict gcheck .setglobal
+ //pdfdict /.Qqwarning_issued //true .forceput
.setglobal
pdfformaterror
- } ifelse
+ } executeonly ifelse
} if
} if
pop
@@ -2717,8 +2764,8 @@ currentdict /PDF2PS_matrix_key undef
Repaired % pass Repaired state around the restore
RepairedAnError
PDFSave restore
- currentglobal pdfdict gcheck .setglobal
- pdfdict /.Qqwarning_issued //false .forceput
+ currentglobal //pdfdict gcheck .setglobal
+ //pdfdict /.Qqwarning_issued //false .forceput
.setglobal
/RepairedAnError exch def
/Repaired exch def
@@ -2822,7 +2869,7 @@ currentdict /PDF2PS_matrix_key undef
currentdevice 1 dict dup /ProcessColorModel dup put .getdeviceparams
exch pop exch pop
dup type /nametype ne { cvn } if
- dup { setcolorspace } .internalstopped { pop /DeviceRGB } if
+ dup { setcolorspace } //.internalstopped exec { pop /DeviceRGB } if
} bind executeonly def
% ------ Transparency support ------ %
@@ -2938,7 +2985,7 @@ currentdict /PDF2PS_matrix_key undef
} if
} if
/Form eq {
- dup /Group known {pop pop true exit}{
+ dup /Group known {pop pop //true exit}{
3 index exch resourceusestransparency { not exit } if
} ifelse
} {
@@ -2960,6 +3007,29 @@ currentdict /PDF2PS_matrix_key undef
pop
} ifelse
} if
+ dup /Font knownoget {
+ //false exch
+ {
+ exch pop oforce
+ dup type /dicttype eq {
+ dup /Subtype knownoget {
+ /Type3 eq
+ {
+ 3 index exch resourceusestransparency
+ { pop //true exit } if
+ }
+ {pop} ifelse
+ }
+ {
+ pop
+ }ifelse
+ }
+ { % probably a name object
+ pop
+ }ifelse
+ } forall
+ { pop //true exit } if
+ } if
2 copy //false put % Visited but not in the current chain.
pop //false exit
} loop
@@ -3241,7 +3311,7 @@ currentdict /PDF2PS_matrix_key undef
dup 0 get dup 4 index
eq
} {
- 0 false
+ 0 //false
}ifelse
%% <calling obj_num> <XObjectdict> false value <form object or 0 if not indirect> <boolean>
@@ -3444,13 +3514,13 @@ currentdict /PDF2PS_matrix_key undef
end % pdfdict
.setglobal
-DELAYBIND not {
%% This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
%% Since each operator is a potential security vulnerability, and any operator listed here
%% is not required once the initislisation is complete and functions are bound, we undefine
%% the ones that aren't needed at runtime.
+/.PDF_UNDEF_OPLIST
[
-/.pdfawidthshow /.pdfwidthshow
+/.pdfawidthshow /.pdfwidthshow /.currentblackptcomp /.setblackptcomp
/.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
/.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
@@ -3461,7 +3531,7 @@ DELAYBIND not {
/.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha
/.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
/.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise
-/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
+/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize
/.setdistillerparams
% Used by our own test suite files
@@ -3472,8 +3542,12 @@ DELAYBIND not {
%/.endtransparencygroup % transparency-example.ps
% undefining these causes errors/incorrect output
-%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint
+%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint
%/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
-]
+] def
+
+DELAYBIND not {
+.PDF_UNDEF_OPLIST
{systemdict exch .undef} forall
+systemdict /.PDF_UNDEF_OPLIST .undef
} if