diff options
Diffstat (limited to 'Resource/Init/pdf_draw.ps')
-rw-r--r-- | Resource/Init/pdf_draw.ps | 132 |
1 files changed, 95 insertions, 37 deletions
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps index 1deb0526..a93a526c 100644 --- a/Resource/Init/pdf_draw.ps +++ b/Resource/Init/pdf_draw.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 @@ -749,7 +749,6 @@ def /GroupGState .knownget { setgstate } if newpath //null SMask - 1 .setopacityalpha 1 .setshapealpha 1 CA 1 ca /Compatible .setblendmode % Execute the body of the Form, similar to DoForm. @@ -874,7 +873,15 @@ currentdict /csncompdict undef dup dup 1 oget mark exch { oforce } forall .dicttomark dup dup //true resolvestream - /ReusableStreamDecode filter /DataSource exch put + { + /ReusableStreamDecode filter + } stopped + { + pop null +% ( **** Error: Failed to read ICC profile for an ICCBased colour space.\n) pdfformaterror +% ( Falling back to a colour space determined by the /N value.\n) pdfformaterror + }if + /DataSource exch put dup /.hash 0 put % placeholder for use by seticc icc_profile_cache key % Check that the number of components (/N) defined in the ICCBased % dictionry matches the actual profile. Bug #696120 @@ -1470,7 +1477,7 @@ drawopdict begin /sh { OFFlevels length 0 eq { - setfillstate resolvesh + setsmaskstate resolvesh //sh_save 0 save put PDFusingtransparency { gsave @@ -2284,7 +2291,6 @@ currentdict /last-ditch-bpc-csp undef PDFfile fileposition exch gsave //nodict begin //null .setSMask - 1 .setopacityalpha 1 .setshapealpha 1 CA 1 ca /Compatible .setblendmode DoImage @@ -2303,11 +2309,10 @@ currentdict /last-ditch-bpc-csp undef currentdict /SMask get /Matte known {/CS currentdict /ColorSpace get dup pdfopdict /cs get exec } if >> 0 0 1 1 .begintransparencygroup - .currentstrokeconstantalpha .currentfillconstantalpha .currentshapealpha .currentopacityalpha 5 -1 roll + .currentstrokeconstantalpha .currentfillconstantalpha 3 -1 roll 1 .setfillconstantalpha 1 .setstrokeconstantalpha - 1 .setopacityalpha 1 .setshapealpha doimage - .setopacityalpha .setshapealpha .setfillconstantalpha .setstrokeconstantalpha + .setfillconstantalpha .setstrokeconstantalpha .endtransparencygroup % tell the compositor we're done with the SMask. % Note that any SMask in the ExtGState should be reapplied @@ -2320,10 +2325,10 @@ currentdict /last-ditch-bpc-csp undef % the image doesn't have an SMask, but the ExtGState does, force a group. << /Subtype /Group /Isolated //true >> 0 0 1 1 .begintransparencygroup - .currentstrokeconstantalpha .currentfillconstantalpha .currentshapealpha .currentopacityalpha 5 -1 roll - 1 .setopacityalpha 1 .setshapealpha + .currentstrokeconstantalpha .currentfillconstantalpha 3 -1 roll + 1 .setfillconstantalpha 1 .setstrokeconstantalpha doimage - .setopacityalpha .setshapealpha .setfillconstantalpha .setstrokeconstantalpha + .setfillconstantalpha .setstrokeconstantalpha .endtransparencygroup } { doimage @@ -2410,8 +2415,8 @@ currentdict /last-ditch-bpc-csp undef 4 array astore grestore /image setup_trans - { currentdict end setfillstate //true ValidateDecode { imagemask } } - { ColorSpace setgcolorspace currentdict end setfillblend //false ValidateDecode { image } } + { currentdict end setsmaskstate //true ValidateDecode { imagemask } } + { ColorSpace setgcolorspace currentdict end setsmaskstate //false ValidateDecode { image } } ifelse PDFSTOPONERROR { exec //false } { stopped } ifelse { dup type /dicttype eq { pop } if % Sometimes image fails to restore the stack @@ -2446,7 +2451,7 @@ currentdict /last-ditch-bpc-csp undef /.paintform { % <formdict> <resdict> <stream> .paintform - 1 index /FormResDict gput % For broken forms that inherit resources from the context. - 3 -1 roll dup /Group known PDFusingtransparency and { + 3 -1 roll dup /Group oknown PDFusingtransparency and { .paintgroupform } { pop pdfopdict .pdfruncontext @@ -2630,7 +2635,27 @@ pdfdict } forall } if - 3 index //false /resolvestream cvx + 3 index + % /Contents for the stream is not per the spec, but Acrobat handles it + dup /Contents knownoget + { + % We want to make it's a dictionary, and represents a stream + dup type /dicttype eq + { + dup /FilePosition known + { + PDFSTOPONERROR { /DoForm cvx /undefinedresource signalerror } if + ( **** Error: Invalid Form definition. Output may be incorrect.\n) pdfformaterror + exch pop + } + {pop} ifelse + } + { + pop + } + ifelse + }if + //false /resolvestream cvx /.paintform cvx ] cvx /PaintProc exch put % Adjust pdfemptycount since we have an extra dictionary on the stack @@ -2668,6 +2693,38 @@ pdfdict pop /pdfemptycount exch store + % We've now seen Form XObjects leaving junk on the stack, so we + % can't assume that when we finish the form the stack will be restored + % nor can we assume that the junk won't include a 'mark' so we an't + % simply do a cleartomark. Instead clear the stack until we get back + % to a dictionary which contains /saved_DG. We can still get errors; + % if the stream removes too many objects from the stack we will end + % up with a stackunderflow, but there's nothing we can do about that. + dup type /dicttype eq not { + //true + } { + dup /saved_DG known { + //false + } { + //true + } ifelse + } ifelse + { + ( **** Error: Form stream left garbage on the stack, attempting to recover.\n) pdfformaterror + ( Output may be incorrect.\n) pdfformaterror + { + dup type /dicttype eq not { + pop + } { + dup /saved_DG known { + exit + } { + pop + } ifelse + } ifelse + } loop + } if + %% Put back pre-existing Default* ColorSpace definitions. dup type /dicttype eq { begin @@ -2816,7 +2873,7 @@ drawopdict begin ( Output may be incorrect.\n) pdfformaterror currentdict /qTextSaveMatrix get setmatrix } if - setfillblend + setsmaskstate PDFfile fileposition exch % pos /Name % Bug #698226, Acrobat signals an error for recursive XObjects in a PDF file @@ -3234,7 +3291,7 @@ end {} 2 index /S knownoget { /D eq { 2 index /D knownoget not { {3} } if exch pop } if } if - 3 index /CA knownoget {.setopacityalpha} if + 3 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if 3 -1 roll pop % 2 index annotsetcolor { 0 setdash setlinewidth stroke @@ -3244,7 +3301,7 @@ end % If element 3 of the /Border array is 0, then don't draw the border dup 0 ne { exch dup length 3 gt { 3 get } { pop {} } ifelse - 3 index /CA knownoget {.setopacityalpha} if + 3 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if % 2 index annotsetcolor { 0 setdash setlinewidth stroke % } if @@ -3253,7 +3310,7 @@ end } ifelse } ifelse } { - 3 index /CA knownoget {.setopacityalpha} if + dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if 1 {} % 2 index annotsetcolor { 0 setdash setlinewidth stroke @@ -3265,7 +3322,7 @@ end /fillborderpath { % <annot> fillborderpath - gsave - dup /ca knownoget {.setopacityalpha} if + dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if annotsetinteriorcolor {fill} if grestore @@ -3742,14 +3799,14 @@ currentdict /set_bc_color undef annotsetinteriorcolor { gsave - dup /ca knownoget {.setopacityalpha} if + dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if dup annotrect 5 index /RD knownoget { applyRD } if rectfill grestore - dup /CA knownoget {.setopacityalpha} if + dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if dup annotsetcolor { drawborder } if @@ -3851,10 +3908,10 @@ currentdict /set_bc_color undef { gsave - dup /ca knownoget {.setopacityalpha} if + dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if fill grestore - dup /CA knownoget {.setopacityalpha} if + dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if dup annotsetcolor { strokeborderpath } if @@ -3890,7 +3947,7 @@ currentdict /set_bc_color undef dup 1 index exch lineto dup neg lineto closepath - 1 index /CA knownoget {.setopacityalpha} if + 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if 1 index fillborderpath grestore 3 mul @@ -3916,7 +3973,7 @@ currentdict /set_bc_color undef 2.5 mul dup 0 moveto 0 0 3 -1 roll 0 360 arc - 1 index /CA knownoget {.setopacityalpha} if + 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if 1 index fillborderpath grestore 3 mul dup @@ -3941,7 +3998,7 @@ currentdict /set_bc_color undef dup 0 exch lineto 0 lineto closepath - 1 index /CA knownoget {.setopacityalpha} if + 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if 1 index fillborderpath grestore 3 mul @@ -3991,7 +4048,7 @@ currentdict /set_bc_color undef dup 2 div sub dup 8.4 mul neg 1 index 5.9 mul neg moveto dup 1.2 div neg 0 lineto dup 8.4 mul neg exch 5.9 mul lineto closepath - dup /CA knownoget {.setopacityalpha} if + dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if fillborderpath grestore } bind executeonly def @@ -4050,7 +4107,7 @@ currentdict /set_bc_color undef dup 2 div sub dup 8.4 mul neg 1 index 5.9 mul neg moveto dup 1.2 div neg 0 lineto dup 8.4 mul neg exch 5.9 mul lineto closepath - dup /CA knownoget {.setopacityalpha} if + dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if fillborderpath grestore } bind executeonly def @@ -4090,7 +4147,7 @@ currentdict /set_bc_color undef 3 index aload pop 4 2 roll pop pop translate 0 0 moveto - atan % <annot> [x1 y1 x2 y2] [LE1 LE2] + {atan} stopped {pop pop 0} if % <annot> [x1 y1 x2 y2] [LE1 LE2] rotate dup 1 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1 dup //LineEnd_dict exch known not @@ -4109,7 +4166,7 @@ currentdict /set_bc_color undef 3 index aload pop pop pop translate 0 0 moveto - atan 180 add + {atan} stopped {pop pop 0} if 180 add rotate 0 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec grestore @@ -4137,15 +4194,16 @@ currentdict /set_bc_color undef } { gsave //startannottransparency exec + dup annotsetcolor pop dup /Vertices knownoget { 1 index /LE knownoget { gsave 1 index 0 4 getinterval aload pop 4 2 roll 2 copy translate 4 2 roll - 3 -1 roll sub % x1 x2 dy - 3 1 roll exch sub % dy dx - atan + 3 -1 roll exch sub % x1 x2 dy + 3 1 roll sub % dy dx + {atan} stopped {pop pop 0} if rotate dup 0 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec grestore @@ -4155,7 +4213,7 @@ currentdict /set_bc_color undef 2 copy translate 3 -1 roll sub % x1 x2 dy 3 1 roll exch sub % dy dx - atan + {atan} stopped {pop pop 0} if rotate 1 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec grestore @@ -4514,11 +4572,11 @@ currentdict /set_bc_color undef dup annotrect rectclip dup /CA knownoget { - .setopacityalpha + dup .setstrokeconstantalpha .setfillconstantalpha } if dup /ca knownoget { - .setopacityalpha + dup .setstrokeconstantalpha .setfillconstantalpha } if dup /C knownoget { |