Some test text!

Add a DocTimeStamp signaturekeyboard_arrow_down

Add a DocTimeStamp signature in Python

To add a DocTimeStamp signature:

# 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, Rect(0.0, 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)

print('Testing timestamping configuration.')
config_result = tst_config.TestConfiguration(opts)
if config_result.GetStatus():
    print('Success: timestamping configuration usable. Attempting to timestamp.')
    # Print details of timestamping failure.
    if config_result.HasResponseVerificationResult():
        tst_result = config_result.GetResponseVerificationResult()
        print('CMS digest status: '+ tst_result.GetCMSDigestStatusAsString())
        print('Message digest status: ' + tst_result.GetMessageImprintDigestStatusAsString())
        print('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.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more