For the complete documentation index, see llms.txt. This page is also available as Markdown.

Work with PDF signature fields using JavaScript

Requirements

The following packages are required to use these features in production. Trial keys have unlimited access to all features.

Package: Digital SignatureLive demo

Signature fields will show the text Sign here. Clicking the text opens the signature dialog or signature overlay, depending on whether you have saved signatures. After you create or select a signature, it will scale to the size of the signature field and be added directly to it, instead of showing a signature preview.

Sign a signature field

Sign a field on click

If you want to place a signature on click of a Sign Here field, you can sign it by listening to the locationSelected event. The sign method takes a freehand annotation or a stamp annotation as a parameter. The following example shows how we can use a stamp annotation to sign a signature widget.

Sign a field programmatically

Starting in WebViewer 8.10, signature fields can be signed programmatically using the signSignatureWidget API. This adds a signature to the field using whichever signing mode you use.

Choose annotation or appearance signing

Starting in WebViewer 11, signature fields will be signed by appearance by default. Signing by annotation will still be supported. Signing with an annotation is used primarily for e-signatures that have no additional identifiable information about the creator other than an author field, which can be altered. Signing with a signature appearance, on the other hand, can be used for digital signatures, as they don't create additional annotations and cause invalid digital signature validation.

You can change signing modes using the Signature Tool setSigningMode API.

Apply initials to signature fields

Starting in WebViewer 8.9, signature fields can accept either initials or signatures. For more details on how to set the signature field to accept one or the other, refer to this guide. Please note that the initials feature must be enabled for this to display in the viewer. For a sample, refer to this guide.

If a field is set to accept initials, the initials set by the user in the signature modal will be added to the signature field.

Check a signature field's status

Verify a field is cryptographically signed

Starting in WebViewer 12.2, the SignatureWidgetAnnotation.hasCryptographicSignature API can be used to check if signatures have been cryptographically signed. This API is intended to replace isSignedDigitally.

Verify a field is digitally signed

Info: isSignedDigitally was deprecated in WebViewer 12. Use hasCryptographicSignature instead.

isSignedDigitally returns a promise that will be resolved with a boolean value indicating if the signature field is signed digitally.

Verify a field is signed by appearance

Starting in WebViewer 8.12, you can check if a widget is signed by an appearance using the isSignedByAppearance API.

Get the annotation used to sign a field

When signing a signature widget with an annotation, after the signature annotation (drawing, typing, or image) is added to a signature widget, you can access that annotation through the annot property of the signature widget object.

Customize the Sign here element

createSignHereElement is a function that creates the Sign here element in the annotation field. This function returns a DOM element that will be appended to the field. You can replace this with your own function.

By default, the sign here element has white text and a dark blue background.

You can change the background to red by modifying the returned DOM element directly.

If you want to create your own sign here element, say a div element with inline SVG, you can assign your function to createSignHereElement. The following example uses inline SVG.

Lock fields after signing

You can add a lock when creating a signature field. The lock is triggered when the signature field is signed, and will be applied to the specified target fields. This supports a workflow where you can lock all form fields as read-only after a signature field has been signed to prevent further changes.

Clear a signature from a field

Starting in WebViewer 8.12, signature fields can be cleared using the clearSignature API. This will remove the signature, whether it is an appearance signature or annotation signature, from the field and then redraw it as unsigned.

Last updated

Was this helpful?