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"