From b04a5e3de89c54df0d971a3d5ca8727de994d08c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 14 Feb 2018 12:32:53 +0100 Subject: Use text encoding for pdf_choice_widget options and values. Adds a requirement on the caller to free the returned strings. --- source/pdf/pdf-form.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index d11fb471..bec1799a 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -1166,11 +1166,11 @@ int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw /* If it is a two element array, the second item is the one that we want if we want the listing value. */ if (m == 2) if (exportval) - opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 0)); + opts[i] = pdf_to_utf8(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 0)); else - opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 1)); + opts[i] = pdf_to_utf8(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 1)); else - opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, optarr, i)); + opts[i] = pdf_to_utf8(ctx, pdf_array_get(ctx, optarr, i)); } } return n; @@ -1206,7 +1206,7 @@ int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, if (pdf_is_string(ctx, optarr)) { if (opts) - opts[0] = pdf_to_str_buf(ctx, optarr); + opts[0] = pdf_to_utf8(ctx, optarr); return 1; } @@ -1223,7 +1223,7 @@ int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, if (pdf_is_array(ctx, elem)) elem = pdf_array_get(ctx, elem, 1); - opts[i] = pdf_to_str_buf(ctx, elem); + opts[i] = pdf_to_utf8(ctx, elem); } } @@ -1249,7 +1249,7 @@ void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget for (i = 0; i < n; i++) { - opt = pdf_new_string(ctx, doc, opts[i], strlen(opts[i])); + opt = pdf_new_text_string(ctx, doc, opts[i]); pdf_array_push_drop(ctx, optarr, opt); } @@ -1257,7 +1257,7 @@ void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget } else { - opt = pdf_new_string(ctx, doc, opts[0], strlen(opts[0])); + opt = pdf_new_text_string(ctx, doc, opts[0]); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_V, opt); } -- cgit v1.2.3