PdfSignatureBuilder(IExternalSigner) Constructor
Initializes a new instance of the PdfSignatureBuilder class with specified settings.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public PdfSignatureBuilder(
IExternalSigner signer
)
#Parameters
Name | Type | Description |
---|---|---|
signer | IExternal |
An object used to generate a signature. |
#Remarks
Use this class constructor to create and sign a new signature form field.
#Sign with a PKCS#7 Signature
The PDF Document API supports PKCS#7 signatures. The Pkcs7Signer class represents this signature type. You can create a Pkcs7SignerBase descendant to use custom PKCS#7 signature implementation.
The signature form field’s name and bounds are determined automatically. Use the PdfSignatureFieldInfo object to specify information about the signature form field’s name, bounds and rotation angle.
The code sample below shows how to create and sign a new signature form field:
//Load a document to be signed
using (var signer = new PdfDocumentSigner("SignedDocument.pdf"))
{
//Specify the name and location of the signature field
var description = new PdfSignatureFieldInfo(1);
description.Name = "SignatureField";
description.SignatureBounds = new PdfRectangle(10, 10, 150, 150);
//Create a PKCS#7 signature
Pkcs7Signer signature = new Pkcs7Signer("Signing Documents//testcert.pfx", "123", HashAlgorithmType.SHA256);
//Apply a signature to a new form field
var signatureBuilder = new PdfSignatureBuilder(signature, description);
//Specify the signature's image and signer information
signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("Signing Documents//Signature.jpg"));
signatureBuilder.Location = "USA";
signatureBuilder.Name = "Jane Cooper";
//Sign and save the document
signer.SaveDocument("out2.pdf", signatureBuilder);
}