PdfFileSignature Class
Contents
[
Hide
]
- PDF Signing
- PDF Certification
- Signature Management
- Signature Verification
- Signature Information
- Signature Integrity Checks
- Revision & Permissions
- Signature Extraction
- Usage Rights Management
Preparing PDF Digital Signature Helpers
Before applying a digital signature to a PDF, it’s a best practice to set up a group of reusable helper functions. These functions encapsulate common tasks—like initializing the signature handler, defining the signature’s visual placement, and configuring certificate-based signing—so your main signing logic stays clean, consistent, and easy to maintain.
What This Setup Achieves
This helper layer prepares everything needed for a smooth signing workflow:
- Initializes a PdfFileSignature object and binds it to a document
- Defines where the signature will appear on the page
- Loads and applies a signing certificate
- Creates a reusable PKCS#7 signature object with metadata
- Customizes how the signature looks visually
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
DEFAULT_CERTIFICATE_PASSWORD = "Aspose2021"
DEFAULT_SIGNATURE_NAME = "Signature1"
def create_pdf_file_signature(infile):
pdf_signature = pdf_facades.PdfFileSignature()
pdf_signature.bind_pdf(infile)
return pdf_signature
def create_signature_rectangle():
return apd.Rectangle(10, 10, 200, 60)
def configure_signature_certificate(
pdf_signature, certificate_path, certificate_password=DEFAULT_CERTIFICATE_PASSWORD
):
pdf_signature.set_certificate(certificate_path, certificate_password)
def create_pkcs7_signature(
certificate_path, certificate_password=DEFAULT_CERTIFICATE_PASSWORD
):
signature = ap.forms.PKCS7(certificate_path, certificate_password)
signature.reason = "Document approval"
signature.contact_info = "qa@example.com"
signature.location = "New York, USA"
signature.authority = "Aspose.PDF Example"
return signature
def create_custom_signature_appearance():
appearance = ap.forms.SignatureCustomAppearance()
appearance.font_family_name = "Arial"
appearance.font_size = 10
appearance.show_contact_info = True
appearance.show_location = True
appearance.show_reason = True
return appearance