Some test text!

menu
Add a DocTimeStamp signaturekeyboard_arrow_down

Add a DocTimeStamp signature in Ruby

To add a DocTimeStamp signature:

doc = PDFDoc.new(in_docpath);
doctimestamp_signature_field = doc.CreateDigitalSignatureField();
tst_config = TimestampingConfiguration.new('http://adobe-timestamp.globalsign.com/?signature=sha2');
opts = VerificationOptions.new(VerificationOptions::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.

    opts.AddTrustedCertificate(in_trusted_cert_path);
# 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).

opts.EnableOnlineCRLRevocationChecking(true);

widgetAnnot = SignatureWidget.Create(doc, Rect.new(0.0, 100.0, 200.0, 150.0), doctimestamp_signature_field);
doc.GetPage(1).AnnotPushBack(widgetAnnot);

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

puts('Testing timestamping configuration.');
config_result = tst_config.TestConfiguration(opts);
if (config_result.GetStatus())
    puts('Success: timestamping configuration usable. Attempting to timestamp.');
else
    # Print details of timestamping failure.
    puts(config_result.GetString());
    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());
    end
    return false;
end

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

close

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.