summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps120
1 files changed, 85 insertions, 35 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
index a93a526ca85..8527312c10c 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2020 Artifex Software, Inc.
+% Copyright (C) 2001-2021 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -762,6 +762,24 @@ def
.pdfruncontext
end grestore
+
+ % check for extra garbage on the operand stack and clean it up
+ count pdfemptycount sub dup 0 ne {
+ ( **** Error: Transparency Group, Form XObject execution corrupted the stack.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ PDFSTOPONERROR {
+ /.execgroup cvx /rangecheck signalerror
+ } {
+ dup 0 gt {
+ { pop } repeat
+ }{
+ pop
+ } ifelse
+ } ifelse
+ } {
+ pop
+ } ifelse
+
/pdfemptycount exch store
} bind executeonly def
@@ -796,12 +814,22 @@ def
%% as arguments to .execgroup
mark currentcolor counttomark array astore exch pop
currentcolorspace 5 2 roll
-
- dup /Group oget exch /BBox oget
+ dup /Group oget dup type /dicttype eq {
+ exch /BBox oget dup type /arraytype eq {
% Stack: resdict stream groupdict bbox
- .beginformgroup
- .execgroup
- .endtransparencygroup
+ .beginformgroup
+ .execgroup
+ .endtransparencygroup
+ }{
+ ( **** Error: Form XObject has a BBox entry with an invalid type.\n) pdfformaterror
+ ( Ignoring transparency Group, output may be incorrect.\n) pdfformaterror
+ pop pop pop pop pop pop
+ } ifelse
+ } {
+ ( **** Error: Form XObject has a Group entry with an invalid type.\n) pdfformaterror
+ ( Ignoring transparency Group, output may be incorrect.\n) pdfformaterror
+ pop pop pop pop pop pop
+ } ifelse
} bind executeonly def
% Make an ImageType 103 (soft-masked) image.
@@ -2169,7 +2197,15 @@ currentdict /last-ditch-bpc-csp undef
( Output may be incorrect.\n) pdfformaterror
} ifelse
} if
- 1 index /Mask knownoget { 1 index exch /Mask exch put } if
+ 1 index /Mask knownoget {
+ dup type dup /dicttype eq exch /arraytype eq or { % Bug #703681
+ 1 index exch /Mask exch put
+ } {
+ pop
+ ( **** Error: Ignoring Mask attribute that is not an array or a dictionary.\n)
+ pdfformaterror
+ } ifelse
+ } if
makeimagedict doimagesmask
} bind executeonly def
/makemaskimage { % <datasource> <imagemask> <Mask> makemaskimage
@@ -2287,6 +2323,14 @@ currentdict /last-ditch-bpc-csp undef
currentdict /SMask knownoget {
% We are doing transparency and SMask is present in the image
% stack: <imagemask> <SMask>
+ % Normalize /Matte attribute for .begintransparencymaskimage
+ dup /Matte .knownget {
+ oforce dup //null eq {
+ pop dup /Matte undef
+ } {
+ 1 index /Matte [ 4 -1 roll { oforce } forall ] put
+ } ifelse
+ } if
.begintransparencymaskimage
PDFfile fileposition exch
gsave //nodict begin
@@ -2308,6 +2352,12 @@ currentdict /last-ditch-bpc-csp undef
% code only picks up the current colour space, not the space from the dictionary.
currentdict /SMask get /Matte known {/CS currentdict /ColorSpace get dup pdfopdict /cs get exec } if
>> 0 0 1 1
+ gsave 1 1 moveto 0 0 lineto
+ % If we get an error, just emit an empty box
+ { pathbbox } stopped { 0 0 0 0 } if
+ 4 array astore grestore
+ /image
+ setup_trans
.begintransparencygroup
.currentstrokeconstantalpha .currentfillconstantalpha 3 -1 roll
1 .setfillconstantalpha 1 .setstrokeconstantalpha
@@ -2409,12 +2459,6 @@ currentdict /last-ditch-bpc-csp undef
makemaskimage
} if
% Stack: datasource imagemask
- gsave 1 1 moveto 0 0 lineto
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- 4 array astore grestore
- /image
- setup_trans
{ currentdict end setsmaskstate //true ValidateDecode { imagemask } }
{ ColorSpace setgcolorspace currentdict end setsmaskstate //false ValidateDecode { image } }
ifelse
@@ -3008,6 +3052,12 @@ drawopdict begin
/File PDFsource def
currentdict makeimagekeys
OFFlevels length 0 eq {
+ gsave 1 1 moveto 0 0 lineto
+ % If we get an error, just emit an empty box
+ { pathbbox } stopped { 0 0 0 0 } if
+ 4 array astore grestore
+ /image
+ setup_trans
doimage
} {
pop Width
@@ -4252,7 +4302,7 @@ currentdict /set_bc_color undef
dup annotsetcolor {
dup drawborder dup calc_annot_scale
2 copy mul 0 ne
- {3 -1 roll drawwidget //false}
+ {3 -1 roll drawwidget}
{
pop pop
( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
@@ -4260,6 +4310,7 @@ currentdict /set_bc_color undef
}ifelse
} if
//endannottransparency exec
+ //false
} bind executeonly def
/Ink { % <annot> -> <annot> <true>
@@ -5359,14 +5410,9 @@ currentdict /drawannottypes undef
/Ink {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/Line {
- mark exch dup /L .knownget {
- aload 5 1 roll transform 4 -2 roll transform 4 2 roll
- 5 -1 roll astore
- 1 index /L 3 -1 roll put
- } if
- loadannot /ANN pdfmark //false
-} bind executeonly def
+/PolyLine {mark exch loadannot /ANN pdfmark //false} bind executeonly def
+
+/Line {mark exch loadannot /ANN pdfmark //false} bind executeonly def
/Link {
/NO_PDFMARK_DESTS where {pop NO_PDFMARK_DESTS not}{//true}ifelse
@@ -5456,7 +5502,8 @@ currentdict /drawannottypes undef
//false
} bind executeonly def
-/Movie {mark exch loadannot /ANN pdfmark //false} bind executeonly def
+%% We don't handle movies correctly, so don't try to preserve them
+%/Movie {mark exch loadannot /ANN pdfmark //false} bind executeonly def
/Popup {mark exch loadannot /ANN pdfmark //false} bind executeonly def
/Sound {mark exch loadannot /ANN pdfmark //false} bind executeonly def
/Square {mark exch loadannot /ANN pdfmark //false} bind executeonly def
@@ -5717,22 +5764,25 @@ currentdict end def
% The recursive enumeration of the form fields doesn't descend into widget annotations.
/draw_form_field { % <field> draw_form_field -
- dup /Kids knownoget { % field []
- dup length 0 gt {
- dup 0 oget /Parent knownoget { % field [] kid
- pop % mon-terminal field % field []
- exch pop % []
- { oforce draw_form_field } forall
+ dup type /dicttyype eq { % File for Bug692447 has 'null' Fields entries
+ % This matches what pdf_main process_trailer_attrs
+ dup /Kids knownoget { % field []
+ dup length 0 gt {
+ dup 0 oget /Parent knownoget { % field [] kid
+ pop % mon-terminal field % field []
+ exch pop % []
+ { oforce draw_form_field } forall
+ } {
+ pop draw_terminal_field % separate annots % -
+ } ifelse
} {
- pop draw_terminal_field % separate annots % -
+ ( **** Error: Ignoring empty /Kids array in Form field.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
} ifelse
} {
- ( **** Error: Ignoring empty /Kids array in Form field.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
+ draw_terminal_field % merged annotation % -
} ifelse
- } {
- draw_terminal_field % merged annotation % -
- } ifelse
+ } if
} bind executeonly def
/draw_acro_form { % <form> draw_acro_form -