Add a Timestamp Signature to a PDF File in C#

void AddTimestampSignatureToPdf(string unsignedDoc, string stampedDoc)
{
    PdfSignature ps = new PdfSignature("");

    //load the PDF document
    ps.LoadPdfDocument(unsignedDoc);

    ps.TimeStamping.ServerUrl = new Uri("https://ca.signfiles.com/TSAServer.aspx");
    ps.TimeStamping.UserName = "your_username";
    ps.TimeStamping.Password = "your_password";

    ps.TimeStamping.HashAlgorithm = SignLib.HashAlgorithm.SHA256;

    //write the timestamped PDF file
    File.WriteAllBytes(stampedDoc,  ps.ApplyTimestampSignature());
}

See also: