diff options
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-device.c | 4 | ||||
-rw-r--r-- | source/pdf/pdf-op-run.c | 19 | ||||
-rw-r--r-- | source/pdf/pdf-page.c | 6 | ||||
-rw-r--r-- | source/pdf/pdf-run.c | 22 |
4 files changed, 39 insertions, 12 deletions
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index ba51265a..34aab893 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -977,7 +977,7 @@ pdf_dev_end_mask(fz_context *ctx, fz_device *dev) } static void -pdf_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int isolated, int knockout, int blendmode, float alpha) +pdf_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, fz_colorspace *cs, int isolated, int knockout, int blendmode, float alpha) { pdf_device *pdev = (pdf_device*)dev; pdf_document *doc = pdev->doc; @@ -987,7 +987,7 @@ pdf_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int is pdf_dev_end_text(ctx, pdev); - num = pdf_dev_new_form(ctx, &form_ref, pdev, bbox, isolated, knockout, alpha, NULL); + num = pdf_dev_new_form(ctx, &form_ref, pdev, bbox, isolated, knockout, alpha, cs); /* Do we have an appropriate blending extgstate already? */ { diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c index 2e6d9cac..56c84cd9 100644 --- a/source/pdf/pdf-op-run.c +++ b/source/pdf/pdf-op-run.c @@ -13,7 +13,7 @@ typedef struct pdf_material_s pdf_material; typedef struct pdf_run_processor_s pdf_run_processor; -static void pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf_obj *page_resources, const fz_matrix *transform); +static void pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf_obj *page_resources, const fz_matrix *transform, int is_smask); enum { @@ -150,7 +150,7 @@ begin_softmask(fz_context *ctx, pdf_run_processor *pr, softmask_save *save) fz_try(ctx) { fz_begin_mask(ctx, pr->dev, &mask_bbox, gstate->luminosity, mask_colorspace, gstate->softmask_bc, &gstate->fill.color_params); - pdf_run_xobject(ctx, pr, softmask, save->page_resources, &fz_identity); + pdf_run_xobject(ctx, pr, softmask, save->page_resources, &fz_identity, 1); } fz_always(ctx) fz_drop_colorspace(ctx, mask_colorspace); @@ -193,7 +193,7 @@ pdf_begin_group(fz_context *ctx, pdf_run_processor *pr, const fz_rect *bbox, sof pdf_gstate *gstate = begin_softmask(ctx, pr, softmask); if (gstate->blendmode) - fz_begin_group(ctx, pr->dev, bbox, 1, 0, gstate->blendmode, 1); + fz_begin_group(ctx, pr->dev, bbox, NULL, 1, 0, gstate->blendmode, 1); return pr->gstate + pr->gtop; } @@ -527,7 +527,7 @@ pdf_show_image(fz_context *ctx, pdf_run_processor *pr, fz_image *image) { /* apply blend group even though we skip the soft mask */ if (gstate->blendmode) - fz_begin_group(ctx, pr->dev, &bbox, 0, 0, gstate->blendmode, 1); + fz_begin_group(ctx, pr->dev, &bbox, NULL, 0, 0, gstate->blendmode, 1); fz_clip_image_mask(ctx, pr->dev, image->mask, &image_ctm, &bbox); } else @@ -635,7 +635,7 @@ pdf_show_path(fz_context *ctx, pdf_run_processor *pr, int doclose, int dofill, i else { knockout_group = 1; - fz_begin_group(ctx, pr->dev, &bbox, 0, 1, FZ_BLEND_NORMAL, 1); + fz_begin_group(ctx, pr->dev, &bbox, NULL, 0, 1, FZ_BLEND_NORMAL, 1); } } @@ -780,7 +780,7 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr) else { knockout_group = 1; - fz_begin_group(ctx, pr->dev, &tb, 0, 1, FZ_BLEND_NORMAL, 1); + fz_begin_group(ctx, pr->dev, &tb, NULL, 0, 1, FZ_BLEND_NORMAL, 1); } } @@ -1197,7 +1197,7 @@ pdf_set_pattern(fz_context *ctx, pdf_run_processor *pr, int what, pdf_pattern *p } static void -pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf_obj *page_resources, const fz_matrix *transform) +pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf_obj *page_resources, const fz_matrix *transform, int is_smask) { pdf_run_processor *pr = (pdf_run_processor *)proc; pdf_gstate *gstate = NULL; @@ -1262,7 +1262,8 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf * if it throws an error, we must call fz_end_group. */ cleanup_state = 2; fz_begin_group(ctx, pr->dev, &bbox, - pdf_xobject_isolated(ctx, xobj), + pdf_xobject_colorspace(ctx, xobj), + (is_smask ? 1 : pdf_xobject_isolated(ctx, xobj)), pdf_xobject_knockout(ctx, xobj), gstate->blendmode, gstate->fill.alpha); @@ -1983,7 +1984,7 @@ static void pdf_run_Do_image(fz_context *ctx, pdf_processor *proc, const char *n static void pdf_run_Do_form(fz_context *ctx, pdf_processor *proc, const char *name, pdf_xobject *xobj, pdf_obj *page_resources) { - pdf_run_xobject(ctx, (pdf_run_processor*)proc, xobj, page_resources, &fz_identity); + pdf_run_xobject(ctx, (pdf_run_processor*)proc, xobj, page_resources, &fz_identity, 0); } /* marked content */ diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 0a7f968e..1830409a 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -562,6 +562,12 @@ pdf_page_contents(fz_context *ctx, pdf_page *page) return pdf_dict_get(ctx, page->obj, PDF_NAME_Contents); } +pdf_obj * +pdf_page_group(fz_context *ctx, pdf_page *page) +{ + return pdf_dict_get(ctx, page->obj, PDF_NAME_Group); +} + void pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox, fz_matrix *page_ctm) { diff --git a/source/pdf/pdf-run.c b/source/pdf/pdf-run.c index 14dc4ed0..1d823277 100644 --- a/source/pdf/pdf-run.c +++ b/source/pdf/pdf-run.c @@ -51,7 +51,27 @@ pdf_run_page_contents_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *p contents = pdf_page_contents(ctx, page); if (page->transparency) - fz_begin_group(ctx, dev, fz_transform_rect(&mediabox, &local_ctm), 1, 0, 0, 1); + { + fz_colorspace *colorspace = NULL; + pdf_obj *group = pdf_page_group(ctx, page); + + if (group) + { + pdf_obj *cs = pdf_dict_get(ctx, group, PDF_NAME_CS); + if (cs) + { + fz_try(ctx) + { + colorspace = pdf_load_colorspace(ctx, cs); + } + fz_catch(ctx) + { + colorspace = NULL; + } + } + } + fz_begin_group(ctx, dev, fz_transform_rect(&mediabox, &local_ctm), colorspace, 1, 0, 0, 1); + } proc = pdf_new_run_processor(ctx, dev, &local_ctm, usage, NULL, 0); fz_try(ctx) |