diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-02-14 12:32:38 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-02-27 12:58:56 +0100 |
commit | c2ff52c4821922f9288cc2010e937b2a3a5488f1 (patch) | |
tree | 37c7f22aedfd9332a88edf0cd423edd47cbfd83e | |
parent | e4900061bdc4a400bf53dae50d39f4314e3cfe84 (diff) | |
download | mupdf-c2ff52c4821922f9288cc2010e937b2a3a5488f1.tar.xz |
Use proper encoding for pdf_field_value and update_field_value.
-rw-r--r-- | source/pdf/pdf-field.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-form.c | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/source/pdf/pdf-field.c b/source/pdf/pdf-field.c index bdaaf4b0..97479d54 100644 --- a/source/pdf/pdf-field.c +++ b/source/pdf/pdf-field.c @@ -62,7 +62,7 @@ char *pdf_get_string_or_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj) char *pdf_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field) { - return pdf_get_string_or_stream(ctx, doc, pdf_get_inheritable(ctx, doc, field, PDF_NAME_V)); + return pdf_load_stream_or_string_as_utf8(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME_V)); } int pdf_get_field_flags(fz_context *ctx, pdf_document *doc, pdf_obj *obj) diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 88737ce4..d11fb471 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -54,7 +54,6 @@ static void pdf_field_mark_dirty(fz_context *ctx, pdf_document *doc, pdf_obj *fi static void update_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *obj, const char *text) { - pdf_obj *sobj; pdf_obj *grp; if (!text) @@ -66,8 +65,7 @@ static void update_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *obj, if (grp) obj = grp; - sobj = pdf_new_string(ctx, doc, text, strlen(text)); - pdf_dict_put_drop(ctx, obj, PDF_NAME_V, sobj); + pdf_dict_put_text_string(ctx, obj, PDF_NAME_V, text); pdf_field_mark_dirty(ctx, doc, obj); } @@ -531,7 +529,7 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj) if (val && grp) { - pdf_obj *v = pdf_new_string(ctx, doc, val, strlen(val)); + pdf_obj *v = pdf_new_text_string(ctx, doc, val); pdf_dict_put_drop(ctx, grp, PDF_NAME_V, v); recalculate(ctx, doc); } @@ -870,7 +868,7 @@ void pdf_field_set_button_caption(fz_context *ctx, pdf_document *doc, pdf_obj *f { if (pdf_field_type(ctx, doc, field) == PDF_WIDGET_TYPE_PUSHBUTTON) { - pdf_obj *val = pdf_new_string(ctx, doc, text, strlen(text)); + pdf_obj *val = pdf_new_text_string(ctx, doc, text); pdf_dict_putl_drop(ctx, field, val, PDF_NAME_MK, PDF_NAME_CA, NULL); pdf_field_mark_dirty(ctx, doc, field); } |