PdfFileSignature

PdfFileSignature

Overview

PdfFileSignature is a class in Aspose.PDF FOSS for .NET. Inherits from: IDisposable.

Facade for signing and reading digital signatures in PDF documents.

This class declares 72 methods for PdfFileSignature objects in .NET programs. Available methods include: BindPdf, Certify, Close, ContainsSignature, ContainsUsageRights, CoversWholeDocument, Dispose, ExtractCertificate, ExtractImage, GetAccessPermissions, GetBlankSignNames, GetBlankSignatureNames, and 24 additional methods. Public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package. Properties: Document, IsCertified, IsLtvEnabled, SignatureAppearance, SignatureAppearanceStream.

Properties

NameTypeAccessDescription
DocumentDocumentReadThe bound document, lazily opened from the bound PDF bytes, for reading its fields / signatures.
IsCertifiedboolReadTrue when the bound document is certified — i.e.
SignatureAppearancestringRead/WritePath to an image used as the visible signature appearance graphic.
SignatureAppearanceStreamStream?Read/WriteStream of bytes for the visible signature appearance graphic.
IsLtvEnabledboolReadTrue iff the document carries a /DSS (Document Security Store) entry in the catalog — the marker for LTV (long-term validation) enabled signatures.

Methods

SignatureDescription
Dispose()Calls Dispose on this PdfFileSignature instance.
Close()Releases the bound document and its data; same as Dispose.
PdfFileSignature()Creates a signature facade with no document bound; call BindPdf before use.
PdfFileSignature(document: Document)Creates a signature facade bound to the given document.
PdfFileSignature(document: Document, outputFile: string)Creates a signature facade bound to the given document that Save() writes to outputFile.
PdfFileSignature(inputFile: string)Creates a signature facade bound to the PDF file at the given path.
PdfFileSignature(inputFile: string, outputFile: string)Creates a signature facade bound to the PDF file at inputFile that Save() writes to outputFile.
BindPdf(inputFile: string)Binds the PDF file at the given path.
BindPdf(input: byte[])Binds the PDF held in the given byte array.
BindPdf(inputStream: Stream)Reads the whole stream (from the start when it is seekable) and binds that PDF.
BindPdf(document: Document)Binds the given document, using its original file bytes so existing signatures stay valid.
GetSignNames()Returns the field names of all signatures in the bound document.
GetSignNames(onlyActive: bool)Active signatures only when onlyActive is true; otherwise returns every signature field that carries a /V value (matches the parameterless overload).
GetSignatureNames()All signed signature fields wrapped as SignatureName entries (the partial+full+HasSignature shape callers expect).
GetSignatureNames(onlyActive: bool)Filter on signature activity — same predicate as GetSignNames(bool).
GetBlankSignNames()Names of signature fields that exist on the form but carry no signature value (/V entry absent).
GetBlankSignatureNames()Calls GetBlankSignatureNames on this PdfFileSignature instance.
GetRevision(signName: string)Revision index of the named signature (1-based) — counts signatures in the order they appear in the field tree.
GetRevision(signName: SignatureName)Calls GetRevision(signName) on this PdfFileSignature instance.
GetTotalRevision()Total number of signatures present in the document (1-based max revision returned by GetRevision(string)).
CoversWholeDocument(signName: string)Whether the named signature covers the entire bound document (i.e.
CoversWholeDocument(signName: SignatureName)Calls CoversWholeDocument(signName) on this PdfFileSignature instance.
RemoveSignature(signName: SignatureName)Removes the value of the named signature, leaving an empty signature field.
RemoveSignature(signName: SignatureName, removeField: bool)Removes the named signature: the whole signature field when removeField is true, otherwise only its value.
GetSignerName(signName: SignatureName)Calls GetSignerName(signName) on this PdfFileSignature instance.
GetReason(signName: SignatureName)Calls GetReason(signName) on this PdfFileSignature instance.
GetLocation(signName: SignatureName)Calls GetLocation(signName) on this PdfFileSignature instance.
GetContactInfo(signName: SignatureName)Calls GetContactInfo(signName) on this PdfFileSignature instance.
GetDateTime(signName: SignatureName)Calls GetDateTime(signName) on this PdfFileSignature instance.
GetSignerName(signName: string)Calls GetSignerName(signName) on this PdfFileSignature instance.
GetReason(signName: string)Calls GetReason(signName) on this PdfFileSignature instance.
GetLocation(signName: string)Calls GetLocation(signName) on this PdfFileSignature instance.
GetContactInfo(signName: string)Calls GetContactInfo(signName) on this PdfFileSignature instance.
GetDateTime(signName: string)Calls GetDateTime(signName) on this PdfFileSignature instance.
IsCoversWholeDocument(signName: string)Calls IsCoversWholeDocument(signName) on this PdfFileSignature instance.
RemoveSignature(signName: string)Removes the value of the named signature, leaving an empty signature field.
RemoveSignature(signName: string, removeField: bool)Remove the signature value (removeField false) or the entire signature field (true) by name.
RemoveSignatures()Calls RemoveSignatures on this PdfFileSignature instance.
IsContainSignature()Returns true if contain signature is set.
ContainsSignature()Returns true when the bound document contains at least one signature.
Save(outputFile: string)Writes the bound document, including any signatures added or removed, to the given file.
Save(outputStream: Stream)Writes the bound document, including any signatures added or removed, to the stream and rewinds the stream when it is seekable.
Save()Save the bound (possibly signed) document to the outputFile argument from the ctor.
SetCertificate(pfx: string, pass: string)Load a signing certificate from a PFX/PKCS#12 file.
Sign(page: int, SigReason: string, SigContact: string, SigLocation: string, visible: bool, annotRect: System.Drawing.Rectangle)Sign with the previously-loaded SetCertificate certificate.
Sign(page: int, visible: bool, annotRect: System.Drawing.Rectangle, sig: Forms.Signature)Sign on the given page using the certificate embedded in sig.
Sign(page: int, SigReason: string, SigContact: string, SigLocation: string, visible: bool, annotRect: System.Drawing.Rectangle, sig: Forms.Signature)Sign on the given page with explicit metadata, using the certificate embedded in sig.
Sign(page: int, SigName: string, SigReason: string, SigContact: string, SigLocation: string, visible: bool, annotRect: System.Drawing.Rectangle, sig: Forms.Signature)Sign with explicit field name + metadata.
Sign(SigName: string, sig: Forms.Signature)Sign an existing blank signature field by name.
Sign(SigName: string, SigReason: string, SigContact: string, SigLocation: string, sig: Forms.Signature)Sign an existing blank signature field by name with explicit metadata.
Certify(page: int, SigReason: string, SigContact: string, SigLocation: string, visible: bool, annotRect: System.Drawing.Rectangle, docMdpSignature: Forms.DocMDPSignature)Sign on the given page with a /DocMDP reference so the resulting signature is a certifying signature (PDF 32000-1 §12.8.2.2).
Certify(sigName: string, docMdpSignature: Forms.DocMDPSignature)Certify an existing blank signature field by name.
ExtractImage(signName: string)Extract the /AP /N (normal appearance) stream of the named signature’s widget.
ExtractImage(signName: SignatureName)Returns the image shown in the appearance of the named signature, or null when there is none or the name is null.
ToByteArray()FOSS-only convenience: return the bound (possibly signed) PDF bytes.
GetAccessPermissions()Read the certifying signature’s /DocMDP /P access-permission level (1, 2, or 3 per PDF 32000-1 §12.8.2.2).
VerifySignature(signName: SignatureName)Returns true when the named signature is intact and valid; false when the name is null.
ExtractCertificate(signName: SignatureName)Returns the signing certificate of the named signature as a stream of DER-encoded (.cer) bytes, or null when it cannot be found or the name is null.
TryExtractCertificate(signName: SignatureName, stream: Stream)Open bound PDF bytes, re-authenticating with the captured password when the document is encrypted. The bound document, opened from its bytes - for the compromise detector.
TryExtractCertificate(signName: SignatureName, certificate: System.Security.Cryptography.X509Certificates.X509Certificate2)A document over - the bound bytes or a prefix of them - opened with the captured password when there is one.
VerifySignature(signName: string)Returns true when the named signature is intact and valid.
TryVerifySignature(signName: SignatureName, verificationResult: VerificationResult)Non-throwing signature verification.
ExtractCertificate(signName: string)Extract the X.509 signing certificate from the named signature field and return it as a memory stream of DER-encoded bytes (.cer format).
ContainsUsageRights()Returns true when the bound document carries usage rights (a /UR or /UR3 entry in /Perms).
RemoveUsageRights()Removes the usage rights (/UR and /UR3) from the bound document.
VerifySigned(signName: string)Verifies that a signed signature is intact.
VerifySignature(signName: string, options: Security.ValidationOptions, validationResult: Security.ValidationResult)Verify a signature with explicit options + return a ValidationResult describing the outcome.
VerifySignature(signName: string, publicKeyCertificate: System.Security.Cryptography.X509Certificates.X509Certificate2, options: Security.ValidationOptions, validationResult: Security.ValidationResult)Calls VerifySignature(signName, publicKeyCertificate, options, validationResult) on this PdfFileSignature instance.
VerifySignature(signName: Facades.SignatureName, publicKeyCertificate: System.Security.Cryptography.X509Certificates.X509Certificate2)Cert-pinned verify without ValidationOptions.
VerifySignature(signName: Facades.SignatureName, options: Security.ValidationOptions, validationResult: Security.ValidationResult)Calls VerifySignature(signName, options, validationResult) on this PdfFileSignature instance.
VerifySignature(signName: Facades.SignatureName, publicKeyCertificate: System.Security.Cryptography.X509Certificates.X509Certificate2, options: Security.ValidationOptions, validationResult: Security.ValidationResult)Calls VerifySignature(signName, publicKeyCertificate, options, validationResult) on this PdfFileSignature instance.
GetSignaturesInfo()Per-signature algorithm/digest/standard triple, parsed from each signature’s PKCS#7 /Contents.

See Also

 English