From 1a00605a10398aba023555e11d26a15337be3579 Mon Sep 17 00:00:00 2001 From: cameroncaci Date: Tue, 4 Feb 2025 15:55:40 -0500 Subject: [PATCH] expand relaxed validation for outlines --- pkg/pdfcpu/validate/xReftable.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/pdfcpu/validate/xReftable.go b/pkg/pdfcpu/validate/xReftable.go index 7061059b..0fefae45 100644 --- a/pkg/pdfcpu/validate/xReftable.go +++ b/pkg/pdfcpu/validate/xReftable.go @@ -1052,7 +1052,7 @@ func validateRootObject(ctx *model.Context) error { {validateCollection, OPTIONAL, model.V17}, {validateNeedsRendering, OPTIONAL, model.V17}, } { - if !f.required && xRefTable.Version() < f.sinceVersion { + if !f.required && xRefTable.Version() < f.sinceVersion || isValidateOutlines(f.validate) { // Ignore optional fields if currentVersion < sinceVersion // This is really a workaround for explicitly extending relaxed validation. continue @@ -1079,6 +1079,11 @@ func validateRootObject(ctx *model.Context) error { return err } +// Helper func to compare two funcs, go doesn't allow direct comparisons +func isValidateOutlines(f func(*model.XRefTable, types.Dict, bool, model.Version) error) bool { + return fmt.Sprintf("%p", f) == fmt.Sprintf("%p", validateOutlines) +} + func validateAdditionalStreams(xRefTable *model.XRefTable) error { // Out of spec scope. return nil