Fix combo field appearances not being shown

This commit is contained in:
Adrian-George Bostan 2020-06-09 21:20:05 +03:00
parent 6cb58f6327
commit ae490ec28e
2 changed files with 11 additions and 8 deletions

View File

@ -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 {

View File

@ -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