PDF Certification

Aspose.PDF for Python via .NET lets you certify PDF documents by applying a document-level signature with PdfFileSignature. Certification is different from a standard approval signature because it defines what changes, if any, are allowed after the document has been certified.

This article demonstrates two common certification workflows:

  1. Certify a PDF and allow form filling after certification.
  2. Certify a PDF and prevent any further changes.

Certify a PDF for form filling

Use this approach when the document should remain certified but users still need to complete interactive forms or continue signing the file. The FILLING_IN_FORMS permission level allows those controlled changes while keeping the certification valid.

import aspose.pdf.facades as pdf_facades
import sys
from os import path


def certify_pdf_with_mdp_signature(infile, outfile, certificate_path):
    pdf_signature = create_pdf_file_signature(infile)
    try:
        doc_mdp_signature = create_doc_mdp_signature(
            certificate_path,
            ap.forms.DocMDPAccessPermissions.FILLING_IN_FORMS,
            reason="Certified for form filling and signing",
        )
        pdf_signature.certify(
            1,
            "Certified for form filling and signing",
            "security@example.com",
            "New York, USA",
            True,
            create_signature_rectangle(),
            doc_mdp_signature,
        )
        pdf_signature.save(outfile)
    finally:
        pdf_signature.close()

Apply document-level certification with no changes allowed

Use this mode when the certified document must remain unchanged after certification. The NO_CHANGES permission level is appropriate for finalized PDFs where any later modification should invalidate the certification state.

import aspose.pdf.facades as pdf_facades
import sys
from os import path


def apply_document_level_certification(infile, outfile, certificate_path):
    pdf_signature = create_pdf_file_signature(infile)
    try:
        doc_mdp_signature = create_doc_mdp_signature(
            certificate_path,
            ap.forms.DocMDPAccessPermissions.NO_CHANGES,
            reason="Certified with no further changes allowed",
        )
        pdf_signature.certify(
            1,
            "Certified with no further changes allowed",
            "security@example.com",
            "New York, USA",
            True,
            create_signature_rectangle(),
            doc_mdp_signature,
        )
        pdf_signature.save(outfile)
    finally:
        pdf_signature.close()