Skip to content

Commit 84cdec0

Browse files
committed
Fix #948
1 parent 007356f commit 84cdec0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/pdfcpu/validate/annotation.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,25 @@ func validateAnnotationDictLink(xRefTable *model.XRefTable, d types.Dict, dictNa
377377

378378
func validateAnnotationDictFreeTextPart1(xRefTable *model.XRefTable, d types.Dict, dictName string) error {
379379

380+
required := REQUIRED
381+
380382
// DA, required, string
381383
validate := validateDA
382384
if xRefTable.ValidationMode == model.ValidationRelaxed {
385+
383386
validate = validateDARelaxed
387+
388+
// An existing AP entry takes precedence over a DA entry.
389+
d1, err := validateDictEntry(xRefTable, d, dictName, "AP", OPTIONAL, model.V12, nil)
390+
if err != nil {
391+
return err
392+
}
393+
if len(d1) > 0 {
394+
required = OPTIONAL
395+
}
384396
}
385-
da, err := validateStringEntry(xRefTable, d, dictName, "DA", REQUIRED, model.V10, validate)
397+
398+
da, err := validateStringEntry(xRefTable, d, dictName, "DA", required, model.V10, validate)
386399
if err != nil {
387400
return err
388401
}

0 commit comments

Comments
 (0)