diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2022-10-28 15:24:41 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2022-10-28 15:24:41 +0100 |
commit | c359d43c8825bbaaf3c71385853b45a3a148a6f3 (patch) | |
tree | c2b87d719465e314fdb05e9d83e9ddf090fc05b1 /psi | |
parent | c7b3217163bc8ba46486a58cc4ceea3b2c7d3a37 (diff) | |
download | ghostpdl-c359d43c8825bbaaf3c71385853b45a3a148a6f3.tar.gz |
GhostPDF + GS - fix ShowAnnotTypes and PreserveAnnotTypes
Bug #706036 "-dPreserveAnnots=false disregards /ShowAnnotTypes []"
There were a couple of problems here. Firstly the switches were
mis-spelled as SHOWANNOTTYPES and PRESERVEANNOTTYPES in both pdf_main.ps
(passing the values to the PDF interpreter) and in the PDF interpreter
itself. This meant that neither switch was being processed.
In addition the code to read the values was incorrectly assuming that
the value was a 'list' of strings. This is not the case for either
control, and indeed simply isn't possible in PostScript. In both cases
the value should be an array of names.
The code now accepts an array of either names or strings for both keys
from PostScript.
Diffstat (limited to 'psi')
-rw-r--r-- | psi/zpdfops.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/psi/zpdfops.c b/psi/zpdfops.c index 1a082d638..50b4f56a1 100644 --- a/psi/zpdfops.c +++ b/psi/zpdfops.c @@ -1195,18 +1195,42 @@ static int zpdfi_glyph_index(gs_font *pfont, byte *str, uint size, uint *glyph) return 0; } -static int param_value_get_namelist(pdf_context *ctx, ref *pvalueref, char ***pstrlist) +static int param_value_get_namelist(gs_memory_t *ps_mem, pdf_context *ctx, ref *pvalueref, char ***pstrlist) { char *data; - uint size; + uint size, count; + char **strlist = NULL; + ref lval, sref; + int code; + + check_read_type(*pvalueref, t_array); + + strlist = (char **)gs_alloc_bytes(ctx->memory, (r_size(pvalueref)+1)*sizeof(char *), "param_value_get_namelist"); + if (strlist == NULL) + return_error(gs_error_VMerror); + memset(strlist, 0x00, (r_size(pvalueref)+1)*sizeof(char *)); + + for (count = 0;count < r_size(pvalueref); count++) { + code = array_get(ps_mem, pvalueref, count, &lval); + if (code < 0) + return code; - if (!r_has_type(pvalueref, t_string)) - return_error(gs_error_typecheck); + if (!r_has_type(&lval, t_string) && !r_has_type(&lval, t_name)) + return_error(gs_error_typecheck); - data = (char *)pvalueref->value.bytes; - size = pvalueref->tas.rsize; + if (r_has_type(&lval, t_name)) + name_string_ref(ps_mem, (const ref *)&lval, &sref); + else + sref = lval; - return pdfi_parse_name_cstring_array(ctx, data, size, pstrlist); + strlist[count] = (char *)gs_alloc_bytes(ctx->memory, sref.tas.rsize + 1, "param_value_get_namelist"); + if (strlist[count] == NULL) + return_error(gs_error_VMerror); + memset(strlist[count], 0x00, sref.tas.rsize + 1); + memcpy(strlist[count], sref.value.bytes, sref.tas.rsize); + } + *pstrlist = strlist; + return 0; } static int zPDFInit(i_ctx_t *i_ctx_p) @@ -1435,14 +1459,14 @@ static int zPDFInit(i_ctx_t *i_ctx_p) goto error; pdfctx->ctx->args.pdfinfo = pvalueref->value.boolval; } - if (dict_find_string(pdictref, "SHOWANNOTTYPES", &pvalueref) > 0) { - code = param_value_get_namelist(pdfctx->ctx, pvalueref, + if (dict_find_string(pdictref, "ShowAnnotTypes", &pvalueref) > 0) { + code = param_value_get_namelist(imemory, pdfctx->ctx, pvalueref, &pdfctx->ctx->args.showannottypes); if (code < 0) goto error; } - if (dict_find_string(pdictref, "PRESERVEANNOTTYPES", &pvalueref) > 0) { - code = param_value_get_namelist(pdfctx->ctx, pvalueref, + if (dict_find_string(pdictref, "PreserveAnnotTypes", &pvalueref) > 0) { + code = param_value_get_namelist(imemory, pdfctx->ctx, pvalueref, &pdfctx->ctx->args.preserveannottypes); if (code < 0) goto error; |