From 5a0cd0a9b9888389eb367f64480d35a88bab6376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hern=C3=A1ndez?= Date: Mon, 26 Feb 2024 16:33:00 +0100 Subject: [PATCH] fix: add embedded file(s) to catalog --- sign/pdfcatalog.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sign/pdfcatalog.go b/sign/pdfcatalog.go index 4c79acb..6837dc2 100644 --- a/sign/pdfcatalog.go +++ b/sign/pdfcatalog.go @@ -12,16 +12,28 @@ func (context *SignContext) createCatalog() (catalog string, err error) { root := context.PDFReader.Trailer().Key("Root") root_keys := root.Keys() found_pages := false + found_names := false for _, key := range root_keys { if key == "Pages" { found_pages = true break } } + for _, key := range root_keys { + if key == "Names" { + found_names = true + break + } + } rootPtr := root.GetPtr() context.CatalogData.RootString = strconv.Itoa(int(rootPtr.GetID())) + " " + strconv.Itoa(int(rootPtr.GetGen())) + " R" + if found_names { + names := root.Key("Names").GetPtr() + catalog += " /Names " + strconv.Itoa(int(names.GetID())) + " " + strconv.Itoa(int(names.GetGen())) + " R" + } + if found_pages { pages := root.Key("Pages").GetPtr() catalog += " /Pages " + strconv.Itoa(int(pages.GetID())) + " " + strconv.Itoa(int(pages.GetGen())) + " R"