aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-10-04 13:29:22 +0200
committerPřemysl Janouch <p@janouch.name>2018-10-04 14:14:04 +0200
commit9d2412398ad51e31048ae61f42955f04f85d292f (patch)
tree90649c421f28d83a816494b843940fca4a835b05
parent62206ed344097fa2232dbb75d96ed2ea60841ec4 (diff)
downloadpdf-simple-sign-9d2412398ad51e31048ae61f42955f04f85d292f.tar.gz
pdf-simple-sign-9d2412398ad51e31048ae61f42955f04f85d292f.tar.xz
pdf-simple-sign-9d2412398ad51e31048ae61f42955f04f85d292f.zip
Go: additional small fixes
-rw-r--r--cmd/pdf-simple-sign/main.go4
-rw-r--r--pdf/pdf.go8
2 files changed, 7 insertions, 5 deletions
diff --git a/cmd/pdf-simple-sign/main.go b/cmd/pdf-simple-sign/main.go
index 11aadaa..7c82786 100644
--- a/cmd/pdf-simple-sign/main.go
+++ b/cmd/pdf-simple-sign/main.go
@@ -64,9 +64,9 @@ func main() {
die(3, "%s", err)
}
if pdfDocument, err = pdf.Sign(pdfDocument, key, certs); err != nil {
- die(2, "error: %s", err)
+ die(4, "error: %s", err)
}
if err = ioutil.WriteFile(outputPath, pdfDocument, 0666); err != nil {
- die(3, "%s", err)
+ die(5, "%s", err)
}
}
diff --git a/pdf/pdf.go b/pdf/pdf.go
index 17a4982..1616b0d 100644
--- a/pdf/pdf.go
+++ b/pdf/pdf.go
@@ -795,7 +795,8 @@ type BytesWriter interface {
WriteString(s string) (n int, err error)
}
-// Update appends an updated object to the end of the document.
+// Update appends an updated object to the end of the document. The fill
+// callback must write exactly one PDF object.
func (u *Updater) Update(n uint, fill func(buf BytesWriter)) {
oldRef := u.xref[n]
u.updated[n] = struct{}{}
@@ -880,7 +881,8 @@ func NewDate(ts time.Time) Object {
return NewString(string(buf))
}
-// GetFirstPage retrieves the first page of the document or a Nil object.
+// GetFirstPage retrieves the first page of the given page (sub)tree reference,
+// or returns a Nil object if unsuccessful.
func (u *Updater) GetFirstPage(nodeN, nodeGeneration uint) Object {
obj, _ := u.Get(nodeN, nodeGeneration)
if obj.Kind != Dict {
@@ -1126,7 +1128,7 @@ func Sign(document []byte,
buf.WriteString("\n /Contents <")
signOff = buf.Len()
- signLen = 8192 // cert, digest, encripted digest, ...
+ signLen = 8192 // cert, digest, encrypted digest, ...
buf.Write(bytes.Repeat([]byte{'0'}, signLen))
buf.WriteString("> >>")