summaryrefslogtreecommitdiff
path: root/pdf/pdf_gstate.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2021-11-08 13:37:03 +0000
committerKen Sharp <ken.sharp@artifex.com>2021-11-08 13:37:03 +0000
commit1538a3cf288d935645f8b9d2caac79d802c8f4c0 (patch)
tree99e4c3c37e29d0ab791f79e40c10e398561f932b /pdf/pdf_gstate.c
parent3f84ac0435ff4ddbc7dd3c8514fd7cae299bc0ca (diff)
downloadghostpdl-1538a3cf288d935645f8b9d2caac79d802c8f4c0.tar.gz
GhostPDF - clamp invalid constant alpha values
Bug 704700 "PDF to PNG - Dropping annotations" The annotations all use an ExtGState which has CA and ca values of 255. The spec is clear that valid values lie in the range 0.0 to 1.0. While this is an example of an invalid file we can render it correctly by clamping out of rang values to the top or bottom of the range, and this commit does that, along with adding a new warning that this has been done. We don't plan to address this in the old PostScript-based interpreter.
Diffstat (limited to 'pdf/pdf_gstate.c')
-rw-r--r--pdf/pdf_gstate.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/pdf/pdf_gstate.c b/pdf/pdf_gstate.c
index 7544aa484..1ea6abc11 100644
--- a/pdf/pdf_gstate.c
+++ b/pdf/pdf_gstate.c
@@ -2199,6 +2199,16 @@ static int GS_CA(pdf_context *ctx, pdf_dict *GS, pdf_dict *stream_dict, pdf_dict
if (code < 0)
return code;
+ if (d1 > 1.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_CA", NULL);
+ d1 = 1.0;
+ }
+
+ if (d1 < 0.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_CA", NULL);
+ d1 = 0.0;
+ }
+
code = gs_setstrokeconstantalpha(ctx->pgs, d1);
return code;
}
@@ -2212,6 +2222,16 @@ static int GS_ca(pdf_context *ctx, pdf_dict *GS, pdf_dict *stream_dict, pdf_dict
if (code < 0)
return code;
+ if (d1 > 1.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_ca", NULL);
+ d1 = 1.0;
+ }
+
+ if (d1 < 0.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_ca", NULL);
+ d1 = 0.0;
+ }
+
code = gs_setfillconstantalpha(ctx->pgs, d1);
return code;
}