fix: add embedded file(s) to catalog

This commit is contained in:
Daniel Hernández
2024-02-26 16:33:00 +01:00
committed by Paul van Brouwershaven
parent 8b036403a6
commit 5a0cd0a9b9

View File

@@ -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"