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"
)
@@ -21,22 +20,21 @@ func (context *SignContext) createVisualSignature() (visual_signature string, er
}
}
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"
first_page, err := findFirstPage(root.Key("Pages"))
if err != nil {
return "", err
if found_pages {
first_page, err := findFirstPage(root.Key("Pages"))
if err != nil {
return "", err
}
first_page_ptr := first_page.GetPtr()
visual_signature += " /P " + strconv.Itoa(int(first_page_ptr.GetID())) + " " + strconv.Itoa(int(first_page_ptr.GetGen())) + " R"
}
first_page_ptr := first_page.GetPtr()
visual_signature += " /P " + strconv.Itoa(int(first_page_ptr.GetID())) + " " + strconv.Itoa(int(first_page_ptr.GetGen())) + " R"
visual_signature += " /F 132"
visual_signature += " /FT /Sig"
visual_signature += " /T " + pdfString("Signature")