summaryrefslogtreecommitdiff
path: root/pdf/pdf_image.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-10-17 14:45:15 +0100
committerKen Sharp <ken.sharp@artifex.com>2022-10-17 14:46:27 +0100
commit35ef934765b1da9726258eb0df25834d7984cf46 (patch)
treec76bc211a547b5449ffdbf94b6aac8e4ab86448b /pdf/pdf_image.c
parent45a27a3b7d45fc75c2f9bf96cb877036f6c7e6c2 (diff)
downloadghostpdl-35ef934765b1da9726258eb0df25834d7984cf46.tar.gz
GhostPDF - preserve current colour around transparency groups
Bug #705966 " Problem with transparency of a white box turning black (PDF exported from LibreOffice)" The PDF file has a Form XObject which fills a rectangle but does not set the colour or colour space before doing so; it 'inherits' the colour and colour space in force at the time the Form is executed. However, the Form also has a transparency Group, and that Group has a /CS (colour space) which differs from the parent. We were preserving the current colour space by retrieving the space before calling pdfi_trans_begin_form_group(), which sets the colour space before calling gs_beging_transparency_group(), and the setting the space back after pdfi_trans_begin_form_group, but we were not preserving the color value(s). This commit additionally retrieves the current colour, and modifies pdfi_form_execgroup() to take a client_color as well as a pointer to a colour space, and set both the space and the colour before running the Form content stream. This retains the colour and space at the time the form was executed while still setting the colour space correctly for the Group.
Diffstat (limited to 'pdf/pdf_image.c')
-rw-r--r--pdf/pdf_image.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index bcf2a1fa0..a268fd50b 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -2223,7 +2223,7 @@ int pdfi_EI(pdf_context *ctx)
/* see .execgroup */
int pdfi_form_execgroup(pdf_context *ctx, pdf_dict *page_dict, pdf_stream *xobject_obj,
- gs_gstate *GroupGState, gs_color_space *pcs, gs_matrix *matrix)
+ gs_gstate *GroupGState, gs_color_space *pcs, gs_client_color *pcc, gs_matrix *matrix)
{
int code;
pdfi_int_gstate *igs = (pdfi_int_gstate *)ctx->pgs->client_data;
@@ -2243,6 +2243,9 @@ int pdfi_form_execgroup(pdf_context *ctx, pdf_dict *page_dict, pdf_stream *xobje
code = pdfi_gs_setcolorspace(ctx, pcs);
if (code < 0)
goto exit2;
+ code = gs_setcolor(ctx->pgs, (const gs_client_color *)pcc);
+ if (code < 0)
+ goto exit2;
}
/* Disable the SMask */
@@ -2448,6 +2451,7 @@ static int pdfi_do_form(pdf_context *ctx, pdf_dict *page_dict, pdf_stream *form_
pdf_stream *hacked_stream = NULL;
pdf_dict *form_dict;
gs_color_space *pcs = NULL;
+ gs_client_color cc, *pcc;
#if DEBUG_IMAGES
dbgmprintf(ctx->memory, "pdfi_do_form BEGIN\n");
@@ -2509,12 +2513,14 @@ static int pdfi_do_form(pdf_context *ctx, pdf_dict *page_dict, pdf_stream *form_
/* Save the current color space in case it gets changed */
pcs = gs_currentcolorspace(ctx->pgs);
rc_increment(pcs);
+ pcc = (gs_client_color *)gs_currentcolor(ctx->pgs);
+ cc = *pcc;
code = pdfi_trans_begin_form_group(ctx, page_dict, form_dict);
(void)pdfi_loop_detector_cleartomark(ctx);
if (code < 0) goto exit1;
- code = pdfi_form_execgroup(ctx, page_dict, form_stream, NULL, pcs, NULL);
+ code = pdfi_form_execgroup(ctx, page_dict, form_stream, NULL, pcs, &cc, NULL);
code1 = pdfi_trans_end_group(ctx);
if (code == 0) code = code1;
} else {