diff --git a/annotator/field_appearance.go b/annotator/field_appearance.go index 633a1056..fdacaaf6 100644 --- a/annotator/field_appearance.go +++ b/annotator/field_appearance.go @@ -821,18 +821,21 @@ func genFieldComboboxAppearance(form *model.PdfAcroForm, wa *model.PdfAnnotation } } + // See section 12.7.4.4 "Choice Fields" (pp. 444-446 PDF32000_2008). dchoiceapp := core.MakeDict() for _, optObj := range fch.Opt.Elements() { + if optArr, ok := core.GetArray(optObj); ok && optArr.Len() == 2 { + optObj = optArr.Get(1) + } + var optstr string if opt, ok := core.GetString(optObj); ok { + optstr = opt.Decoded() + } else if opt, ok := core.GetName(optObj); ok { optstr = opt.String() } else { - if opt, ok := core.GetName(optObj); ok { - optstr = opt.String() - } else { - common.Log.Debug("ERROR: Opt not a name/string - %T", optObj) - return nil, errors.New("not a name/string") - } + common.Log.Debug("ERROR: Opt not a name/string - %T", optObj) + return nil, errors.New("not a name/string") } if len(optstr) > 0 { diff --git a/model/form.go b/model/form.go index 39b3d923..da02c961 100644 --- a/model/form.go +++ b/model/form.go @@ -331,12 +331,12 @@ func fillFieldValue(f *PdfField, val core.PdfObject) error { if len(t.String()) == 0 { return nil } - common.Log.Debug("Unexpected string for button/choice field. Converting to name: '%s'", t.String()) + name := core.MakeName(t.String()) for _, wa := range f.Annotations { wa.AS = name } - f.V = name + f.V = val default: common.Log.Debug("ERROR: UNEXPECTED %s -> %v", f.PartialName(), val) f.V = val