Some test text!

Add a DocTimeStamp signaturekeyboard_arrow_down

Add a DocTimeStamp signature in Ruby

To add a DocTimeStamp signature:

doc =;
doctimestamp_signature_field = doc.CreateDigitalSignatureField();
tst_config ='');
opts =;
# 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).


widgetAnnot = SignatureWidget.Create(doc,, 100.0, 200.0, 150.0), doctimestamp_signature_field);

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

puts('Testing timestamping configuration.');
config_result = tst_config.TestConfiguration(opts);
if (config_result.GetStatus())
    puts('Success: timestamping configuration usable. Attempting to timestamp.');
    # Print details of timestamping failure.
    if config_result.HasResponseVerificationResult()
        tst_result = config_result.GetResponseVerificationResult();
        puts('CMS digest status: '+ tst_result.GetCMSDigestStatusAsString());
        puts('Message digest status: ' + tst_result.GetMessageImprintDigestStatusAsString());
        puts('Trust status: ' + tst_result.GetTrustStatusAsString());
    return false;

doctimestamp_signature_field.TimestampOnNextSave(tst_config, opts);

# Save/signing throws if timestamping fails.
doc.Save(in_outpath, SDFDoc::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.