Back to Devexpress

PdfTimeStamp Class

officefileapi-devexpress-dot-pdf-b84c2577.md

latest3.3 KB
Original Source

PdfTimeStamp Class

Allows you to generate document-level timestamps.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class PdfTimeStamp :
    IExternalSigner
vb
Public Class PdfTimeStamp
    Implements IExternalSigner

Remarks

The PdfTimeStamp is the default IExternalSigner interface implementation. Use this class to generate document-level timestamps.

The TsaClient class allows you to specify the timestamp client. You can create an ITsaClient implementation to use your own timestamp client.

The code sample below creates a document-level timestamp and applies it to a signature form field. The FreeTSA server is used for demonstration purposes as a free trusted TSA client. You may wish to use another client as required.

csharp
using DevExpress.Pdf;
using DevExpress.Office.DigitalSignatures;
using DevExpress.Office.Tsp;

using (var signer = new PdfDocumentSigner("Document.pdf"))
{
    // Create a timestamp:
    ITsaClient tsaClient = new TsaClient(new Uri(@"https://freetsa.org/tsr"), HashAlgorithmType.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 timestamp:
    PdfTimeStamp pdfTimeStamp = new PdfTimeStamp(tsaClient);

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

    // Sign and save the document:
    signer.SaveDocument("SignedDocument.pdf", timeStampSignature);
}
vb
Imports DevExpress.Pdf
Imports DevExpress.Office.DigitalSignatures
Imports DevExpress.Office.Tsp

Using signer = New PdfDocumentSigner("Document.pdf")
  ' Create a timestamp:
  Dim tsaClient As ITsaClient = New TsaClient(New Uri("https://freetsa.org/tsr"), HashAlgorithmType.SHA256)

  ' Create a new signature form field:
  Dim signatureFieldInfo1 = New PdfSignatureFieldInfo(1)
  signatureFieldInfo1.Name = "SignatureField1"
  signatureFieldInfo1.SignatureBounds = New PdfRectangle(200, 200, 250, 250)

  ' Create a document-level timestamp:
  Dim pdfTimeStamp As New PdfTimeStamp(tsaClient)

  ' Apply this timestamp to the form field:
  Dim timeStampSignature = New PdfSignatureBuilder(pdfTimeStamp, signatureFieldInfo1)

  ' Sign and save the document:
  signer.SaveDocument("SignedDocument.pdf", timeStampSignature)
End Using

Implements

IExternalSigner

Inheritance

Object PdfTimeStamp

See Also

PdfTimeStamp Members

DevExpress.Pdf Namespace