Skip to content

Signing

A digital signature may be used to authenticate the identity of a user and the document’s contents. It stores information about the signer and the state of the document when it was signed.

fpdf2 allows to sign documents using PKCS#12 certificates (RFC 7292).

The endesive package is required to do so.

pdf = FPDF()
pdf.add_page()
pdf.sign_pkcs12("certs.p12", password=b"1234")
pdf.output("signed_doc.pdf")

The lower-level sign() method allows to add a signature based on arbitrary key & certificates, not necessarily from a PKCS#12 file.

endesive also provides basic code to check PDFs signatures. examples/pdf-verify.py or the check_signature() function used in fpdf2 unit tests can be good starting points for you, if you want to perform PDF signature control.