Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfTsaClient Class

Allows you to generate timestamps.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public class PdfTsaClient :
    ITsaClient

Remarks

The PdfTsaClient class is the default ITsaClient implementation. Use this class to generate timestamps.

Pass the URI of a timestamp server to the PdfTsaClient constructor. You can specify the username and a password to log into the server. If the server rejects the timestamp request, a TspValidationException is thrown.

Use one of the PdfHashAlgorithm enumeration values to specify the timestamp’s hashing algorithm. Create the IDigestCalculator implementation and pass the newly created object to the PdfTsaClient constructor to provide the digest value calculator to the timestamp.

Add a Timestamp to the PKCS#7 Signature

The code sample below creates a PKCS#7 signature with a timestamp:

using (var signer = new PdfDocumentSigner("Document.pdf"))
{
    //Create a timestamp:
    ITsaClient tsaClient = new PdfTsaClient(new Uri(@"https://freetsa.org/tsr"), PdfHashAlgorithm.SHA256);

    //Create a PKCS#7 signature:
    Pkcs7Signer pkcs7Signature = new Pkcs7Signer("Signing Documents/certificate.pfx", "123", PdfHashAlgorithm.SHA256, tsaClient, null, null, PdfSignatureProfile.PAdES_BES);

    //Apply the signature to an existing form field:
    var santuzzaSignature = new PdfSignatureBuilder(pkcs7Signature, "Sign");

    //Specify an image and signer information:
    santuzzaSignature.SetImageData(System.IO.File.ReadAllBytes("Signing Documents/SantuzzaValentina.jpg"));
    santuzzaSignature.Location = "Australia";
    santuzzaSignature.Name = "Santuzza Valentina";
    santuzzaSignature.Reason = "I Agree";

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

Create a Document-Level Timestamp

The code sample below creates a document-level timestamp and applies it to a signature form field:

using (var signer = new PdfDocumentSigner("Document.pdf"))
{
    //Create a timestamp:
    ITsaClient tsaClient = new PdfTsaClient(new Uri(@"https://freetsa.org/tsr"), PdfHashAlgorithm.SHA256);

    //Create a new signature form field:
    var signatureFieldInfo1 = new PdfSignatureFieldInfo(1);
    signatureFieldInfo1.Name = "SignatureField1";
    signatureFieldInfo1.SignatureBounds = new PdfRectangle(200, 200, 250, 250);

    //Create a document-level time stamp:
    PdfTimeStamp pdfTimeStamp = new PdfTimeStamp(tsaClient);

    //Apply this time stamp to the form field:
    var timeStampSignature = new PdfSignatureBuilder(pdfTimeStamp, signatureFieldInfo1);

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

Implements

Inheritance

Object
PdfTsaClient
See Also