A document time-stamp (RFC 3161, ETSI.RFC3161 signature) proves that a PDF document existed at a given moment and that it was not changed afterwards. No signing certificate is needed: the time-stamp is signed by the Time Stamping Authority (TSA).

How it works

  • Load the document, set the time-stamping server in TimeStamping.ServerUrl and call ApplyTimestampSignature.
  • Servers that require authentication are supported: UserName and Password (HTTP basic authentication) or AuthenticationCertificate (TLS client certificate).
  • The document time-stamps are listed with the signatures of the document, in DocumentProperties.DigitalSignatures.

C# code

/// <summary>
/// Adds a document time-stamp to a PDF file.
/// </summary>
static void AddTimestampToPdfFile(string unsignedPdfFile, string timestampedPdfFile)
{
    PdfSignature pdfSignature = new PdfSignature(LibrarySerialNumber);

    pdfSignature.LoadPdfDocument(unsignedPdfFile);

    // The time-stamping server. A server that requires authentication can be used with the properties UserName and
    // Password (HTTP basic authentication) or AuthenticationCertificate (TLS client certificate).
    pdfSignature.TimeStamping.ServerUrl = TimestampServerUrl;

    // The hash algorithm of the time-stamp request (SHA-256 is the default).
    pdfSignature.TimeStamping.HashAlgorithm = SignLib.HashAlgorithm.SHA256;

    // No signing certificate is needed. The result is the PDF document with the time-stamp added.
    File.WriteAllBytes(timestampedPdfFile, pdfSignature.ApplyTimestampSignature());

    Console.WriteLine("The PDF document time-stamp was created." + Environment.NewLine);
}

/// <summary>
/// Displays the document time-stamps of a PDF file.
/// </summary>
static void PrintPdfTimestamps(string timestampedPdfFile)
{
    PdfSignature pdfSignature = new PdfSignature(LibrarySerialNumber);

    pdfSignature.LoadPdfDocument(timestampedPdfFile);

    // The document time-stamps are listed together with the digital signatures of the document.
    foreach (PdfSignatureInfo signatureInfo in pdfSignature.DocumentProperties.DigitalSignatures)
    {
        Console.WriteLine("Signature name: " + signatureInfo.SignatureName);
        Console.WriteLine("Signature type: " + signatureInfo.SignatureType);
        Console.WriteLine("Time-stamp is valid: " + signatureInfo.SignatureIsValid);
        Console.WriteLine("Time-stamp time: " + signatureInfo.SignatureTime.ToLocalTime());
        Console.WriteLine("Time-stamping authority certificate: " + signatureInfo.SignatureCertificate.Subject);
        Console.WriteLine();
    }

    Console.WriteLine("Done PDF time-stamp verification." + Environment.NewLine);
}

The free server used by the sample is for tests. For legal effect in the European Union use a qualified time-stamping service, such as the eIDAS qualified timestamps of qtsa.eu; to run your own server, see TSA Server.

Run the full sample. The complete Visual Studio project PDF Timestamp Signature is included in the library download, in the folder NET Sample Projects (.NET 8, .NET 9, .NET 10 and .NET 11) and in NET Framework Sample Projects (.NET Framework 4.6.2), with the test files and a test certificate. Without a serial number the library runs in demo mode. Download the library and the samples · User manual

Frequently asked questions

Can I time-stamp a PDF that is already signed?

Yes. The document time-stamp is added in an incremental update and the existing signatures remain valid. This is how a PAdES-LTA archive is renewed.

Can I time-stamp the signature instead of the document?

Yes. Set TimeStamping.ServerUrl on a normal signature: the time-stamp is added to the signature itself (PAdES-B-T).