Skip to content

Commit

Permalink
fix signature initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
3ace committed Mar 25, 2021
1 parent d6f6f67 commit 08d0214
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions signatures/pdf_sign_new_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func addSignature(reader *model.PdfReader, pageNum int, outputPath string) error
signature.SetReason("TestSignatureAppearance Reason")
signature.SetDate(time.Now(), "")

// Initialize signature.
if err := signature.Initialize(); err != nil {
return err
}

opts := annotator.NewSignatureFieldOpts()
opts.FontSize = 8
opts.Rect = []float64{250, 250, 325, 300}
Expand Down Expand Up @@ -157,8 +162,7 @@ func addSignature(reader *model.PdfReader, pageNum int, outputPath string) error
}

// Write output PDF file.
err = appender.WriteToFile(outputPath)
if err != nil {
if err = appender.WriteToFile(outputPath); err != nil {
return err
}

Expand All @@ -180,6 +184,7 @@ func generateSigKeys() (*rsa.PrivateKey, *x509.Certificate, error) {
template := x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{
CommonName: "any",
Organization: []string{"Test Company"},
},
NotBefore: now.Add(-time.Hour),
Expand Down

0 comments on commit 08d0214

Please sign in to comment.