All docs
V20.1
20.2 (EAP/Beta)
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+

PdfDeferredSignatureBuilder Class

Allows you to build a signature for a document hash.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfDeferredSignatureBuilder :
    PdfSignatureBuilder
Public Class PdfDeferredSignatureBuilder
    Inherits PdfSignatureBuilder

Remarks

You can build a signature for a new or existing form field. Use the PdfSignatureFieldInfo object to create a new signature field. Pass the name of an existing field to apply a signature to it.

Pass the PdfDeferredSignatureBuilder object to the PdfDocumentSigner.SignDeferred method to add a signature to the document and obtain the document hash.

The code sample below uses a document hash to apply a signature externally:

using (var signer = new PdfDocumentSigner(File.OpenRead("SignDemo.pdf")))
{
  //Specify the information about the signature metadata:
  var digestCalculator = new PdfDigestCalculator(PdfHashAlgorithm.SHA256);

  var signerInfo = new ExternalSignerInfo(PdfSignatureType.Pkcs7, 8000, digestCalculator);

  //Create a new form field:
  var fieldInfo = new PdfSignatureFieldInfo(1) { SignatureBounds = new PdfRectangle(10, 10, 100, 100) };

  //Apply the metadata to the form field:
  var builder = new PdfDeferredSignatureBuilder(signerInfo, fieldInfo);

  //Add the signature to the document:
  var deferredSigner = signer.SignDeferred(builder);

  //Obtain the document hash and hash algorithm's object identifier:
  var digest = deferredSigner.HashValue;
  var digestAlgorithmOID = digestCalculator.AlgorithmOid;

  //Generate the signature content to insert into the document:
  byte[] signature = CreateSignature(digest, digestAlgorithmOID);

  //Add the signature contents and save the document to the file:
  deferredSigner.Sign("signed.pdf", signature);
}

static byte[] CreateSignature(byte[] digest, string digestAlgorithmOID)
{
  var signer = new Pkcs7Signer(@"SignDemo.pfx", "dxdemo");
  byte[] signature = signer.BuildSignature(digest, digestAlgorithmOID);
  return signature;
}

Inheritance

Object
PdfSignatureBuilder
PdfDeferredSignatureBuilder
See Also