summaryrefslogtreecommitdiff
path: root/pdf/pdf_form.c
diff options
context:
space:
mode:
authorPaul Gardiner <paul@glidos.net>2012-06-22 10:10:12 +0100
committerRobin Watts <robin.watts@artifex.com>2012-06-22 16:50:02 +0100
commit56895fa7c1ecc5e3f1e47e5a3e4234755d573262 (patch)
treec82ada549302e29d4c97c437774c50f869ca96e3 /pdf/pdf_form.c
parent4ad045666d542eea0d90b549a30e84237aee8813 (diff)
downloadmupdf-56895fa7c1ecc5e3f1e47e5a3e4234755d573262.tar.xz
Forms support: correctly locate the field dictionary when setting value
Some fields have separate widget annotations. Some have the widget rolled in. This commit correctly identifies the field when setting the field value, thus fixing bug 693145
Diffstat (limited to 'pdf/pdf_form.c')
-rw-r--r--pdf/pdf_form.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c
index 3120cf10..0971edd1 100644
--- a/pdf/pdf_form.c
+++ b/pdf/pdf_form.c
@@ -716,7 +716,7 @@ static fz_buffer *create_text_appearance(pdf_document *doc, fz_rect *bbox, fz_ma
fz_context *ctx = doc->ctx;
int fontsize;
int variable;
- float height, width;
+ float height, width, full_width;
fz_buffer *fzbuf = NULL;
fz_buffer *fztmp = NULL;
fz_rect rect;
@@ -733,6 +733,7 @@ static fz_buffer *create_text_appearance(pdf_document *doc, fz_rect *bbox, fz_ma
height = rect.y1 - rect.y0;
width = rect.x1 - rect.x0;
+ full_width = bbox->x1 - bbox->x0;
fz_var(fzbuf);
fz_var(fztmp);
@@ -813,7 +814,7 @@ static fz_buffer *create_text_appearance(pdf_document *doc, fz_rect *bbox, fz_ma
else if (info->comb)
{
int i, n = min((int)strlen(text), info->max_len);
- float comb_width = width/info->max_len;
+ float comb_width = full_width/info->max_len;
float char_width = pdf_text_stride(ctx, info->font_rec.font, fontsize, (unsigned char *)"M", 1, FLT_MAX, NULL);
float init_skip = (comb_width - char_width)/2.0;
@@ -1052,11 +1053,12 @@ static int get_matrix(pdf_document *doc, pdf_xobject *form, int q, fz_matrix *mt
static void update_text_field_value(fz_context *ctx, pdf_obj *obj, char *text)
{
- pdf_obj *parent = pdf_dict_gets(obj, "Parent");
pdf_obj *sobj = NULL;
- if (parent)
- obj = parent;
+ /* obj is an annotation. If it isn't also a field then the parent is
+ * the associated field */
+ if (!pdf_dict_gets(obj, "FT"))
+ obj = pdf_dict_gets(obj, "Parent");
fz_var(sobj);
fz_try(ctx)