summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2020-02-24 08:23:59 +0000
committerChris Liddell <chris.liddell@artifex.com>2020-02-26 08:18:49 +0000
commit6badfb362efe0fb4f0c3df106a33ecd5b0265ef7 (patch)
tree9956986cb2d6cea62ab4c8ca25816f766712fa9b
parent3dc65600d6d4eb060398f06f148cfe4f07a82439 (diff)
downloadghostpdl-6badfb362efe0fb4f0c3df106a33ecd5b0265ef7.tar.gz
Implement OPM tracking in pdfwrite
More than somewhat to my surprise, the release testing of 9.51 revealed that pdfwrite was not tracking the state of overprint mode (OPM). It could be set by setdistillerparams, and in no other way. This commit adds tracking the OPM in the graphics state, removes the old overprint_mode variable from the device, but preserves the ability to alter the OPM using setdistillerparms. This also alters the initial state of OPM, the distiller params reference states that the 'factory default' of OPM is 1, but the PDF Reference says that the initial state of OPM is 0. We need to start with the correct setting of OPM so we change it form 1 to 0 in gs_pdfwr.ps. In passing, cast a const gs_gstate * to a gs_gstate * when used by gs_swapcolours_quick, in order to avoid a compiler warning. This causes a small number of progressions in files using OPM (which is rare, its even rarer to actually alter it during the course of the file)
-rw-r--r--Resource/Init/gs_pdfwr.ps2
-rw-r--r--devices/vector/gdevpdfb.h1
-rw-r--r--devices/vector/gdevpdfd.c4
-rw-r--r--devices/vector/gdevpdfg.c23
-rw-r--r--devices/vector/gdevpdfx.h1
5 files changed, 17 insertions, 14 deletions
diff --git a/Resource/Init/gs_pdfwr.ps b/Resource/Init/gs_pdfwr.ps
index 422e66e1a..ed691b9d6 100644
--- a/Resource/Init/gs_pdfwr.ps
+++ b/Resource/Init/gs_pdfwr.ps
@@ -86,7 +86,7 @@ languagelevel 2 .setlanguagelevel
/MonoImageDownsampleThreshold 1.5
/MonoImageFilter /CCITTFaxEncode
/OffOptimizations 0
- /OPM 1
+ /OPM 0
/Optimize //true
/ParseDSCComments //true
/ParseDSCCommentsForDocInfo //true
diff --git a/devices/vector/gdevpdfb.h b/devices/vector/gdevpdfb.h
index d84754048..5ea7a3555 100644
--- a/devices/vector/gdevpdfb.h
+++ b/devices/vector/gdevpdfb.h
@@ -174,7 +174,6 @@ const gx_device_pdf PDF_DEVICE_IDENT =
1 /* Absolute Colorimetric */, /* rendering intent */
0 /*false*/, /* remap_fill_coilor */
0 /*false*/, /* remap_stroke_coilor */
- 0, /* overprint_mode */
gs_no_id, /* halftone_id */
{gs_no_id, gs_no_id, gs_no_id, gs_no_id}, /* transfer_ids */
0, /* transfer_not_identity */
diff --git a/devices/vector/gdevpdfd.c b/devices/vector/gdevpdfd.c
index e7ad75668..4973d71fd 100644
--- a/devices/vector/gdevpdfd.c
+++ b/devices/vector/gdevpdfd.c
@@ -1896,9 +1896,9 @@ gdev_pdf_fill_stroke_path(gx_device *dev, const gs_gstate *pgs, gx_path *ppath,
code = gdev_pdf_fill_path(dev, pgs, ppath, fill_params, pdcolor_fill, pcpath);
if (code < 0)
return code;
- gs_swapcolors_quick(pgs);
+ gs_swapcolors_quick((gs_gstate *)pgs);
code = gdev_pdf_stroke_path(dev, pgs, ppath, stroke_params, pdcolor_stroke, pcpath);
- gs_swapcolors_quick(pgs);
+ gs_swapcolors_quick((gs_gstate *)pgs);
return code;
} else {
bool set_ctm;
diff --git a/devices/vector/gdevpdfg.c b/devices/vector/gdevpdfg.c
index aaa362267..0aa93e53b 100644
--- a/devices/vector/gdevpdfg.c
+++ b/devices/vector/gdevpdfg.c
@@ -82,7 +82,7 @@ pdf_save_viewer_state(gx_device_pdf *pdev, stream *s)
pdev->vgstack[i].halftone_id = pdev->halftone_id;
pdev->vgstack[i].black_generation_id = pdev->black_generation_id;
pdev->vgstack[i].undercolor_removal_id = pdev->undercolor_removal_id;
- pdev->vgstack[i].overprint_mode = pdev->overprint_mode;
+ pdev->vgstack[i].overprint_mode = pdev->state.overprint_mode;
pdev->vgstack[i].smoothness = pdev->state.smoothness;
pdev->vgstack[i].flatness = pdev->state.flatness;
pdev->vgstack[i].text_knockout = pdev->state.text_knockout;
@@ -133,7 +133,7 @@ pdf_load_viewer_state(gx_device_pdf *pdev, pdf_viewer_state *s)
pdev->halftone_id = s->halftone_id;
pdev->black_generation_id = s->black_generation_id;
pdev->undercolor_removal_id = s->undercolor_removal_id;
- pdev->overprint_mode = s->overprint_mode;
+ pdev->state.overprint_mode = s->overprint_mode;
pdev->state.smoothness = s->smoothness;
pdev->state.flatness = s->flatness;
pdev->state.text_knockout = s->text_knockout;
@@ -3058,9 +3058,13 @@ pdf_prepare_drawing(gx_device_pdf *pdev, const gs_gstate *pgs,
}
}
}
- if (pdev->CompatibilityLevel >= 1.3 && pdev->sbstack_depth == bottom) {
- if (pdev->overprint_mode != pdev->params.OPM) {
- if (pdev->params.OPM == 1 && pdev->PDFA == 2) {
+ if (pdev->state.overprint_mode != pdev->params.OPM) {
+ if (pdev->params.OPM != pgs->overprint_mode)
+ ((gs_gstate *)pgs)->overprint_mode = pdev->params.OPM;
+ }
+ if (pdev->CompatibilityLevel >= 1.3 /*&& pdev->sbstack_depth == bottom */) {
+ if (pdev->state.overprint_mode != pgs->overprint_mode) {
+ if (pgs->overprint_mode == 1 && pdev->PDFA == 2) {
switch (pdev->PDFACompatibilityPolicy) {
case 0:
emprintf(pdev->memory,
@@ -3071,7 +3075,8 @@ pdf_prepare_drawing(gx_device_pdf *pdev, const gs_gstate *pgs,
case 1:
emprintf(pdev->memory,
"Setting Overprint Mode to 1\n not permitted in PDF/A-2, overprint mode not set\n\n");
- pdev->params.OPM = 0;
+ /* Deliberately breaking const here in order to force the graphics state overprint mode to be unchanged */
+ ((gs_gstate *)pgs)->overprint_mode = pdev->state.overprint_mode;
break;
case 2:
emprintf(pdev->memory,
@@ -3086,14 +3091,14 @@ pdf_prepare_drawing(gx_device_pdf *pdev, const gs_gstate *pgs,
break;
}
}
- if (pdev->overprint_mode != pdev->params.OPM) {
+ if (pdev->state.overprint_mode != pgs->overprint_mode) {
code = pdf_open_gstate(pdev, ppres);
if (code < 0)
return code;
- code = cos_dict_put_c_key_int(resource_dict(*ppres), "/OPM", pdev->params.OPM);
+ code = cos_dict_put_c_key_int(resource_dict(*ppres), "/OPM", pgs->overprint_mode);
if (code < 0)
return code;
- pdev->overprint_mode = pdev->params.OPM;
+ pdev->params.OPM = pdev->state.overprint_mode = pgs->overprint_mode;
}
}
if (pdev->state.smoothness != pgs->smoothness) {
diff --git a/devices/vector/gdevpdfx.h b/devices/vector/gdevpdfx.h
index 6a02717ca..0e43a0281 100644
--- a/devices/vector/gdevpdfx.h
+++ b/devices/vector/gdevpdfx.h
@@ -622,7 +622,6 @@ struct gx_device_pdf_s {
bool fill_overprint, stroke_overprint;
int rendering_intent;
bool remap_fill_color, remap_stroke_color;
- int overprint_mode;
gs_id halftone_id;
gs_id transfer_ids[4];
int transfer_not_identity; /* bitmask */