Skip to content

Commit ce09a83

Browse files
committed
Fix form field validation.
1 parent 4b9cd31 commit ce09a83

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/pdfcpu/validate/form.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,13 @@ func pageAnnotIndRefForAcroField(xRefTable *model.XRefTable, indRef types.Indire
675675

676676
var apObjNr int
677677
indRef1 := d.IndirectRefEntry("AP")
678-
if indRef1 != nil {
679-
apObjNr = indRef1.ObjectNumber.Value()
678+
if indRef1 == nil && (r.Width() == 0 && r.Height() == 0) {
679+
// Probably a signature field.
680+
return &indRef, nil
680681
}
681682

683+
apObjNr = indRef1.ObjectNumber.Value()
684+
682685
for _, m := range xRefTable.PageAnnots {
683686
annots, ok := m[model.AnnWidget]
684687
if ok {
@@ -690,7 +693,7 @@ func pageAnnotIndRefForAcroField(xRefTable *model.XRefTable, indRef types.Indire
690693
}
691694
}
692695

693-
return nil, nil
696+
return nil, errors.New("pdfcpu: can't repair form fields")
694697
}
695698

696699
func validateFormFieldsAgainstPageAnnotations(xRefTable *model.XRefTable) error {
@@ -704,9 +707,6 @@ func validateFormFieldsAgainstPageAnnotations(xRefTable *model.XRefTable) error
704707
if err != nil {
705708
return err
706709
}
707-
if indRef == nil {
708-
return errors.New("pdfcpu: can't repair form fields")
709-
}
710710
arr1 = append(arr1, *indRef)
711711
}
712712

0 commit comments

Comments
 (0)