Valid signature

This commit is contained in:
Jeroen Bobbeldijk
2017-07-11 08:21:18 +02:00
parent db69b6a4c0
commit 7b19471330
9 changed files with 104 additions and 24 deletions

View File

@@ -1,6 +1,8 @@
package sign
import (
"bitbucket.org/digitorus/pdf"
"errors"
"fmt"
"io"
"math"
@@ -9,6 +11,20 @@ import (
"time"
)
func findFirstPage(parent pdf.Value) (pdf.Value, error) {
value_type := parent.Key("Type").String()
if value_type == "/Pages" {
recurse_parent, recurse_err := findFirstPage(parent.Key("Kids").Index(0))
return recurse_parent, recurse_err
}
if value_type == "/Page" {
return parent, nil
}
return parent, errors.New("Could not find first page.")
}
func pdfString(text string) string {
text = strings.Replace(text, "\\", "\\\\", -1)
text = strings.Replace(text, ")", "\\)", -1)