All docs
V20.2
21.1 (EAP/Beta)
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfSignatureBuilder Class

Allows you to build a signature.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v20.2.Core.dll

Declaration

public class PdfSignatureBuilder

Remarks

The PdfSignatureBuilder class allows you to apply a signature to a new or existing signature form field.

Use the newly created PdfSignatureBuilder object as the PdfDocumentSigner.SaveDocument method parameter to sign and save the target PDF document. Use an array of PdfSignatureBuilder objects to apply multiple signatures.

Supported Signature Types

Use the IExternalSigner implementation to generate a signature. The PDF Document API supports the following signatures:

  • PKCS#7 signatures with x.509 certificates

    You can use the Pkcs7Signer class object as the constructor parameter to provide the PKCS#7 signature. Create the Pkcs7SignerBase class descendant to use a custom object to create the PKCS#7 signature. Pass the PdfSignatureProfile.PAdES_BES enumeration value to the object constructor to generate the PAdEs signature.

  • Document-level timestamps

    The PdfTimeStamp class object allows you to sign a form field with the document-level timestamp. Use the ITsaClient implementation to specify the timestamp client.

Signature's Visual Parameters and Certification Level

The PdfSignatureBuilder class properties allow you to specify the signer's name, location, contact information, and the reason to apply the signature. Call the PdfSignatureBuilder.SetImageData method to specify the signature's image.

Specify the PdfCertificationLevel property to define the changes available to users when the signature is applied. If a user makes a restricted change, the signature becomes invalid.

Examples

Sign an Existing Form Field

Pass the signature field name to the PdfSignatureBuilder object constructor to sign this form field.

using DevExpress.Pdf;
using DevExpress.Office.DigitalSignatures;

//Load a document to be signed
using (var signer = new PdfDocumentSigner("Document.pdf"))
{
    //Create a PKCS#7 signature
    Pkcs7Signer pkcs7Signature = new Pkcs7Signer("Signing Documents//testcert.pfx", "123", HashAlgorithmType.SHA256);

    //Apply a signature to the Sign form field
    var signatureBuilder = new PdfSignatureBuilder(pkcs7Signature, "Sign");

    //Specify the signature's image and signer information:
    signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("Signing Documents//Jane Cooper.jpg"));
    signatureBuilder.Location = "USA";
    signatureBuilder.Name = "Jane Cooper";
    signatureBuilder.Reason = "I Agree";

    //Sign and save the document
    signer.SaveDocument("SignedDocument.pdf", signatureBuilder);
}

Create a New Signature Form Field and Sign It

If you create a new signature field, use the PdfSignatureFieldInfo object to specify the signature form field's parameters (name, bounds, rotation angle, etc.). Pass the object to the PdfSignatureBuilder object constructor. Otherwise, the builder creates an invisible signature form field with a default name.

The code sample below creates and signs a new signature form field:

using DevExpress.Pdf;
using DevExpress.Office.DigitalSignatures;

//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);
}

Inheritance

See Also