[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1819-gce68133
[email protected] (Ken Sharp) Wed, 6 Nov 2019 16:46:50 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via ce681338646435ca064ab2d1b8bde1614e5ed3f1 (commit)
from 4e713293de84b689c4ab358f3e110ea54aa81925 (commit)
----------------------------------------------------------------------
commit ce681338646435ca064ab2d1b8bde1614e5ed3f1
Author: Ken Sharp <[email protected]>
Date: Wed Nov 6 16:46:44 2019 +0000
PDF interpreter - preserve colour space on Image XObjects with Do
No bug number the customer file is large and looks confidential.
The problem is that the PDF file sets a custom colour space, then
draws an image, the image is in a different colour space (DeviceRGB),
the file then sets a new colour in the original space.
The PDF interpreter was changing the colour space in order to draw
the image, but was not resetting it afterwards, which meant that the
attempt to set the colour failed as the colour space was inappropriate.
I'm *amazed* this hasn't arisen before, its so clearly wrong.
This commit gets the colour space before executing the image, and puts
it back again afterwards. We have to be careful to do the restoration
in a stopped context because this code can be called when drawing a
glyph, and we are not permitted to change colour space while in an
uncoloured glyph, it throws an error.
In addition, the appearance generation for /Square annotations (and
other types) was setting the colour space to white and filling the
annotation rectangle, even if the /IC (Interior Color) key was not
present. Acrobat appears not to do this so I've modified the code to
not fill the annotation if there is no /IC in the annotation dictionary.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index f299d11..d4a3701 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -2315,6 +2315,9 @@ currentdict /last-ditch-bpc-csp undef
/doimage { % <imagemask> doimage -
% imagedict is currentdict, gets popped from dstack
+ %% We must save the colour space, in case it gets changed. I did try doing this
+ %% at a higher level (/Do) but that caused numerous problems with pdfwrite.
+ currentcolorspace exch
%% save the current rendering intent
.currentrenderintent exch
@@ -2361,6 +2364,13 @@ currentdict /last-ditch-bpc-csp undef
%% restore the rendering intent
.setrenderingintent
+ %% and restore the colour space. We need to do this in a stopped context because
+ %% if we are rendering a glyph, the cache device will throw an error if we try
+ %% to change colour space (even when the new space is the same as the old space)
+ %% We can't tell if we are rendering a bitmap for a glyph, and its hard to compare
+ %% colour spaces, so just ignore errors for now.
+ {setcolorspace} stopped {pop} if
+
teardown_trans
} bind executeonly def
@@ -3043,7 +3053,7 @@ end
} ifelse
} ifelse
}
- { 0 setgray //true} ifelse
+ { //false } ifelse
} bind executeonly def
% Draw the border. Currently, we ignore requests for beveling, and we
Summary of changes:
Resource/Init/pdf_draw.ps | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)