From bf1f8610311e70177b051d9b8906be1a40ace355 Mon Sep 17 00:00:00 2001 From: Paul van Brouwershaven Date: Mon, 12 May 2025 10:21:10 +0200 Subject: [PATCH] Ensure PDF version is at least 1.5 for SigFlags and UF support --- sign/pdfcatalog.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sign/pdfcatalog.go b/sign/pdfcatalog.go index a8c0d07..b5b8537 100644 --- a/sign/pdfcatalog.go +++ b/sign/pdfcatalog.go @@ -28,9 +28,10 @@ func (context *SignContext) createCatalog() ([]byte, error) { // written in the PDF file (for example, /1.4). // // If an incremental upgrade requires a version that is higher than specified by the document. - // if context.PDFReader.PDFVersion < "2.0" { - // catalog_buffer.WriteString(" /Version /2.0") - // } + // Ensure PDF version is at least 1.5 to support SigFlags in acroFormDict (1.4) and UF in the fileSpecDict (1.5) + if v, err := strconv.ParseFloat(context.PDFReader.PDFVersion, 64); err == nil && v < 1.5 { + catalog_buffer.WriteString(" /Version /1.5") + } // Retrieve the root, its pointer and set the root string root := context.PDFReader.Trailer().Key("Root")