@@ -203,6 +203,36 @@ func (f Form) listBoxValuesAndLock(id, name string) ([]string, bool, bool) {
203203 return nil , false , false
204204}
205205
206+ func locateAPN (xRefTable * model.XRefTable , d types.Dict ) (types.Dict , error ) {
207+
208+ obj , ok := d .Find ("AP" )
209+ if ! ok {
210+ return nil , errors .New ("corrupt form field: missing entry \" AP\" " )
211+ }
212+ d1 , err := xRefTable .DereferenceDict (obj )
213+ if err != nil {
214+ return nil , err
215+ }
216+ if len (d1 ) == 0 {
217+ return nil , errors .New ("corrupt form field: missing entry \" AP\" " )
218+ }
219+
220+ obj , ok = d1 .Find ("N" )
221+ if ! ok {
222+ return nil , errors .New ("corrupt AP field: missing entry \" N\" " )
223+ }
224+ d2 , err := xRefTable .DereferenceDict (obj )
225+ if err != nil {
226+ return nil , err
227+ }
228+
229+ if len (d2 ) == 0 {
230+ return nil , errors .New ("corrupt AP field: missing entry \" N\" " )
231+ }
232+
233+ return d2 , nil
234+ }
235+
206236func extractRadioButtonGroupOptions (xRefTable * model.XRefTable , d types.Dict ) ([]string , bool , error ) {
207237
208238 var opts []string
@@ -232,15 +262,12 @@ func extractRadioButtonGroupOptions(xRefTable *model.XRefTable, d types.Dict) ([
232262 }
233263 }
234264
235- d1 := d .DictEntry ("AP" )
236- if d1 == nil {
237- return nil , false , errors .New ("corrupt form field: missing entry AP" )
238- }
239- d2 := d1 .DictEntry ("N" )
240- if d2 == nil {
241- return nil , false , errors .New ("corrupt AP field: missing entry N" )
265+ d1 , err := locateAPN (xRefTable , d )
266+ if err != nil {
267+ return nil , false , err
242268 }
243- for k := range d2 {
269+
270+ for k := range d1 {
244271 k , err := types .DecodeName (k )
245272 if err != nil {
246273 return nil , false , err
@@ -320,7 +347,8 @@ func extractCheckBox(page int, d types.Dict, id, name, altName string, locked bo
320347 }
321348
322349 if o , ok := d .Find ("V" ); ok {
323- cb .Value = o .(types.Name ) != "Off"
350+ n := o .(types.Name )
351+ cb .Value = len (n ) > 0 && n != "Off"
324352 }
325353
326354 return cb , nil
0 commit comments