Dont parse twice in test, fix some bugs with special pdfs

This commit is contained in:
Jeroen Bobbeldijk
2017-09-17 15:24:57 +02:00
parent b8f3cee07c
commit 8c60336e04
6 changed files with 32 additions and 44 deletions

View File

@@ -1,7 +1,6 @@
package sign
import (
"errors"
"strconv"
)
@@ -20,15 +19,14 @@ func (context *SignContext) createCatalog() (catalog string, err error) {
}
}
if !found_pages {
return "", errors.New("Didn't find pages in PDF trailer Root.")
}
rootPtr := root.GetPtr()
context.CatalogData.RootString = strconv.Itoa(int(rootPtr.GetID())) + " " + strconv.Itoa(int(rootPtr.GetGen())) + " R"
pages := root.Key("Pages").GetPtr()
catalog += " /Pages " + strconv.Itoa(int(pages.GetID())) + " " + strconv.Itoa(int(pages.GetGen())) + " R"
if found_pages {
pages := root.Key("Pages").GetPtr()
catalog += " /Pages " + strconv.Itoa(int(pages.GetID())) + " " + strconv.Itoa(int(pages.GetGen())) + " R"
}
catalog += " /AcroForm <<"
catalog += " /Fields [" + strconv.Itoa(int(context.VisualSignData.ObjectId)) + " 0 R]"