Signature Management
Aspose.PDF for Python via .NET provides the PdfFileSignature facade for working with existing digital signatures in PDF documents. In addition to reading and validating signatures, you can also remove them when a workflow requires the signed content to be updated or the signature field to be cleared.
This example demonstrates two common signature management tasks:
- Remove a signature from a PDF document.
- Remove a signature and clean up the associated signature field.
Remove a signature from a PDF
Use remove_signature() when you want to delete the selected signature from the document while keeping the underlying signature field structure in place. The example opens the signed PDF, resolves the signature name, removes it, and saves the updated output file.
import aspose.pdf.facades as pdf_facades
import sys
from os import path
def remove_signature_from_pdf(infile, outfile):
pdf_signature = create_pdf_file_signature(infile)
try:
sign_name = require_signature_name(pdf_signature)
pdf_signature.remove_signature(sign_name)
pdf_signature.save(outfile)
finally:
pdf_signature.close()
Remove a signature and clean up the field
Use the overload with the additional True flag when you want to remove the signature and also clean up the related signature field. This is useful when the field should not remain in the document after the signature has been deleted.
import aspose.pdf.facades as pdf_facades
import sys
from os import path
def remove_signature_with_field_cleanup(infile, outfile):
pdf_signature = create_pdf_file_signature(infile)
try:
sign_name = require_signature_name(pdf_signature)
pdf_signature.remove_signature(sign_name, True)
pdf_signature.save(outfile)
finally:
pdf_signature.close()