Skip to content

Commit

Permalink
fix: add embedded file(s) to catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hernández authored and vanbroup committed Mar 14, 2024
1 parent 8b03640 commit 5a0cd0a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sign/pdfcatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5a0cd0a

Please sign in to comment.