Some test text!

Add a DocTimeStamp signaturekeyboard_arrow_down

Add a DocTimeStamp signature on Cross-Platform (Core)

To add a DocTimeStamp signature:

using (PDFDoc doc = new PDFDoc(in_docpath))
    DigitalSignatureField doctimestamp_signature_field = doc.CreateDigitalSignatureField();
    TimestampingConfiguration tst_config = new TimestampingConfiguration("");
    VerificationOptions opts = new VerificationOptions(VerificationOptions.SignatureVerificationSecurityLevel.e_compatibility_and_archiving);
    /* It is necessary to add to the VerificationOptions a trusted root certificate corresponding to 
    the chain used by the timestamp authority to sign the timestamp token, in order for the timestamp
    response to be verifiable during DocTimeStamp signing. */
    /* By default, we only check online for revocation of certificates using the newer and lighter 
    OCSP protocol as opposed to CRL, due to lower resource usage and greater reliability. However, 
    it may be necessary to enable online CRL revocation checking in order to verify some timestamps
    (i.e. those that do not have an OCSP responder URL for all non-trusted certificates). */

    SignatureWidget widgetAnnot = SignatureWidget.Create(doc, new Rect(0, 100, 200, 150), doctimestamp_signature_field);
    Obj widgetObj = widgetAnnot.GetSDFObj();

    // (OPTIONAL) Add an appearance to the signature field.
    Image img = Image.Create(doc, in_appearance_img_path);

    Console.WriteLine("Testing timestamping configuration.");
    TimestampingTestResult config_result = tst_config.TestConfiguration(opts);
    if (config_result.GetStatus())
        Console.WriteLine("Success: timestamping configuration usable. Attempting to timestamp.");
        // Print details of timestamping failure.
        if (config_result.HasResponseVerificationResult())
            EmbeddedTimestampVerificationResult tst_result = config_result.GetResponseVerificationResult();
            Console.WriteLine("CMS digest status: %s\n", tst_result.GetCMSDigestStatusAsString());
            Console.WriteLine("Message digest status: %s\n", tst_result.GetMessageImprintDigestStatusAsString());
            Console.WriteLine("Trust status: %s\n", tst_result.GetTrustStatusAsString());
        return false;

    doctimestamp_signature_field.TimestampOnNextSave(tst_config, opts);

    // Save/signing throws if timestamping fails.
    doc.Save(in_outpath, SDFDoc.SaveOptions.e_incremental);

Digital signatures
Full code sample which demonstrates using the digital signature API to digitally sign, certify, and/or verify PDF documents.

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our upcoming webinar to find out about built-in, full-functioning document capabilities directly in Salesforce.

Save your seat