mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-14 19:29:50 +08:00
Fix combo field appearances not being shown
This commit is contained in:
parent
6cb58f6327
commit
ae490ec28e
@ -821,19 +821,22 @@ func genFieldComboboxAppearance(form *model.PdfAcroForm, wa *model.PdfAnnotation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See section 12.7.4.4 "Choice Fields" (pp. 444-446 PDF32000_2008).
|
||||||
dchoiceapp := core.MakeDict()
|
dchoiceapp := core.MakeDict()
|
||||||
for _, optObj := range fch.Opt.Elements() {
|
for _, optObj := range fch.Opt.Elements() {
|
||||||
|
if optArr, ok := core.GetArray(optObj); ok && optArr.Len() == 2 {
|
||||||
|
optObj = optArr.Get(1)
|
||||||
|
}
|
||||||
|
|
||||||
var optstr string
|
var optstr string
|
||||||
if opt, ok := core.GetString(optObj); ok {
|
if opt, ok := core.GetString(optObj); ok {
|
||||||
optstr = opt.String()
|
optstr = opt.Decoded()
|
||||||
} else {
|
} else if opt, ok := core.GetName(optObj); ok {
|
||||||
if opt, ok := core.GetName(optObj); ok {
|
|
||||||
optstr = opt.String()
|
optstr = opt.String()
|
||||||
} else {
|
} else {
|
||||||
common.Log.Debug("ERROR: Opt not a name/string - %T", optObj)
|
common.Log.Debug("ERROR: Opt not a name/string - %T", optObj)
|
||||||
return nil, errors.New("not a name/string")
|
return nil, errors.New("not a name/string")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(optstr) > 0 {
|
if len(optstr) > 0 {
|
||||||
xform, err := makeComboboxTextXObjForm(fch.PdfField, width, height, optstr, style, daOps, form.DR)
|
xform, err := makeComboboxTextXObjForm(fch.PdfField, width, height, optstr, style, daOps, form.DR)
|
||||||
|
@ -331,12 +331,12 @@ func fillFieldValue(f *PdfField, val core.PdfObject) error {
|
|||||||
if len(t.String()) == 0 {
|
if len(t.String()) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
common.Log.Debug("Unexpected string for button/choice field. Converting to name: '%s'", t.String())
|
|
||||||
name := core.MakeName(t.String())
|
name := core.MakeName(t.String())
|
||||||
for _, wa := range f.Annotations {
|
for _, wa := range f.Annotations {
|
||||||
wa.AS = name
|
wa.AS = name
|
||||||
}
|
}
|
||||||
f.V = name
|
f.V = val
|
||||||
default:
|
default:
|
||||||
common.Log.Debug("ERROR: UNEXPECTED %s -> %v", f.PartialName(), val)
|
common.Log.Debug("ERROR: UNEXPECTED %s -> %v", f.PartialName(), val)
|
||||||
f.V = val
|
f.V = val
|
||||||
|
Loading…
x
Reference in New Issue
Block a user