Skip to content

Repository files navigation

PDFCPU Sign

A Go-native PDF signing library, on top of pdfcpu.

Currently, the only implemented signature handler is Adobe PKCS#7 detached (CMS) which is by far the most widely used one.

Simple Usage Example

package main
import (
"crypto""log""time"
pdfcpusign "github.com/agcom/pdfcpu-sign""github.com/agcom/pdfcpu-sign/testutils"
)
funcmain() {
pvKey, _, cert:=testutils.GenKert()
sigHandler:=pdfcpusign.NewAdobePkcs7DetachedSigHandler(pvKey, cert, nil, crypto.SHA256)
err:=pdfcpusign.SignFile(
sigHandler,
"./_samples/minimal.pdf", "./_samples/minimal-signed.pdf",
(&pdfcpusign.SignInfo{
Type: pdfcpusign.SignTypeCert,
DocMdp: pdfcpusign.DocMdpPermNoChanges,
SignerInfo: &pdfcpusign.SignerInfo{
Name: "Alireza",
Location: "Earth",
Reason: "Test",
ContactInfo: "example@example.org",
Time: time.Now(),
},
}).ToSig(),
)
iferr!=nil {
log.Fatalf("Sign PDF failed: %s.\n", err)
}
}

API Application

There is an API application at /cmds/api that utilizes keys over a PKCS#11 interface.

About

Go-native PDF Signing

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages