> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/digital-signature/signature-tool.md).

# Use the digital signature tool in WebViewer

Enhance document security with the Signature tool in WebViewer. Easily add ink, text, or image signatures to your files. Preview and choose from various signature types before applying them. The Aprys

{% hint style="info" %}
**Requirements**

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

<a href="https://apryse.com/capabilities#DigitalSignature" class="button primary">Package: Digital Signature</a><a href="https://showcase.apryse.com/digital-signatures" class="button primary">Live demo</a>
{% endhint %}

In the Insert toolbar group, select the signature tool, then click the **+Signature** button to open the signature modal. Here, users can choose a signature type and preview it before adding it to the document.

Signatures can be one of three types:

* Ink Signatures, where users can choose from one of three colors.

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-c9e73000e00037f1538244f68c28c1b8b9f31be2%2Fddc7e62440c34e247dcee20e4ac0018d5833ae28-600x350.gif?alt=media" alt=""></div>

* Text Signatures, where users can choose from one of three colors and different fonts.

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-b7b9fb48cc3a7d75357d9d80509b8d412747d1db%2F5704ae6171f4f3d97b56245ef01e53f790692e0b-600x350.gif?alt=media" alt=""></div>

* Image Signatures, where users can upload a signature file by dragging and dropping a file or using the file explorer.

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-02846bc5ca7bc0759ce33bd1621f92a942f81e2b%2F942525d853fdd3565e245e0bfa2553b5f003b94b-600x350.gif?alt=media" alt=""></div>

If you have saved signatures, clicking the signature button opens an overlay where you can choose and apply them directly.

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-a13cb2f31e86db51cfea503c1f17c212e78e1634%2Fd759cccb7003da9bd31a52f8b2b8b477494e8b63-600x350.gif?alt=media" alt=""></div>

## Initials as signature

Starting in WebViewer 8.9, the Signature tool supports an additional mode for initials as signatures. This new feature is disabled by default and can be enabled using the following:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  instance.UI.enableFeatures([instance.UI.Feature.Initials]);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

If this feature is enabled, the signature modal will also require initials to be added.

* Ink Signature and Initials

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-25e94771b568b63677ce17f73a0766404febe467%2F92fc96ddbece753ee1a867d05a86eace78d96e80-600x350.gif?alt=media" alt=""></div>

* Text Signature and Initials

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-f388bc3e9de00bbcc09d294180d63e145aa86a91%2F120c7ae448ec5c2f389b078b88105e906c3338d5-600x350.gif?alt=media" alt=""></div>

* Image Signature and Initials

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-8fad490052d67be4d911f7f635e4d54748cd29dc%2Fa0df3e70f87aa9056c6300afa7d391737a5c2fe6-600x350.gif?alt=media" alt=""></div>

Once created, the signature and initials are saved in the signatures overlay, allowing users to choose whether to apply a signature or initials.

<div align="left"><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-3c075b90d0493dc7806b86e7eb918e105151c136%2F6e20b0264e258ae703c1fc4d478e75d145cf9a2f-600x350.gif?alt=media" alt=""></div>

## Import existing signatures

If you already have a signature stored for the user, you can [import](https://sdk.apryse.com/api/web/Core.Tools.SignatureCreateTool.html#importSignatures) it into the signature tool:

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  const { documentViewer } = instance.Core;
  const signatureTool = documentViewer.getTool('AnnotationCreateSignature');

  documentViewer.addEventListener('documentLoaded', () => {
    signatureTool.importSignatures([base64Image]);
  });
});
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  const { docViewer } = instance;
  const signatureTool = docViewer.getTool('AnnotationCreateSignature');

  docViewer.on('documentLoaded', () => {
    signatureTool.importSignatures([base64Image]);
  });
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

You can also save the signature by calling [exportSignatures](https://sdk.apryse.com/api/web/Core.Tools.SignatureCreateTool.html#exportSignatures__anchor).

## Import existing initials

Starting in WebViewer 8.9, you can also import and export a user's initials.

You can [import](https://sdk.apryse.com/api/web/Core.Tools.SignatureCreateTool.html#importInitials) them into the signature tool, which will make them available in the saved signatures overlay. You must have this feature enabled in order to view the saved initials in the viewer.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  const { documentViewer } = instance.Core;
  const signatureTool = documentViewer.getTool('AnnotationCreateSignature');

  documentViewer.addEventListener('documentLoaded', () => {
    signatureTool.importInitials([base64Image]);
  });
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

You can also save them by calling [exportInitials](https://sdk.apryse.com/api/web/Core.Tools.SignatureCreateTool.html#exportInitials__anchor).

## Add custom fonts

By default, `GreatVibes` is the only font that is available in the `Type` tab. More fonts can be added using the [setSignatureFonts](https://sdk.apryse.com/api/web/UI.html#.setSignatureFonts__anchor) API. The following is an example that adds [Tangerine](https://fonts.google.com/specimen/Tangerine/) from Google Fonts to the tab.

{% hint style="info" %}
Google recommends importing fonts in your index.html rather than via CSS for performance reasons. You can read more about Google's recommended methods here: <https://developers.google.com/fonts/docs/css2>
{% endhint %}

Here are two ways to import your fonts in `index.html`:

{% tabs %}
{% tab title="CSS" %}
{% code lineNumbers="true" %}

```css
/* inside <head> of index.html */

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<link
  href="https://fonts.googleapis.com/css2?family=Tangerine&display=swap"
  rel="stylesheet">

```

{% endcode %}
{% endtab %}
{% endtabs %}

Or

{% tabs %}
{% tab title="CSS" %}
{% code lineNumbers="true" %}

```css
/* inside index.html */

<style>
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&display=swap');
</style>
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
  css: 'path/to/stylesheet.css'
}).then(instance => {
  instance.UI.setSignatureFonts(currentFonts => [
    ...currentFonts,
    'Tangerine',
  ]);
});
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
  css: 'path/to/stylesheet.css'
}).then(instance => {
  instance.setSignatureFonts(currentFonts => [
    ...currentFonts,
    'Tangerine',
  ]);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Export a signature to blob storage

If you created a signature and want to store it for later use, you can export it as a blob and save it to an external storage solution. If you are on WebViewer 8.9 and have initials enabled, the following code will also save initials as blobs for storage.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  const { annotationManager, documentViewer } = instance.Core;

  documentViewer.addEventListener('annotationsLoaded', async () => {
      annotationManager.addEventListener('annotationSelected', async (annotationList) => {
          annotationList.forEach(annotation => {
              if (annotation.Subject === "Signature")
                  extractAnnotationSignature(annotation, documentViewer);
          })
      })
  });
});
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...
}).then(instance => {
  const { annotManager, docViewer } = instance;

  docViewer.on('annotationsLoaded', async () => {
      annotManager.on('annotationSelected', async (annotationList) => {
          annotationList.forEach(annotation => {
              if (annotation.Subject === "Signature")
                  extractAnnotationSignature(annotation, docViewer);
          })
      })
  });
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

Sample function to export the signature:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function extractAnnotationSignature(annotation, docViewer) {
    // Create a new Canvas to draw the Annotation on
    const canvas = document.createElement('canvas');
    // Reference the annotation from the Document
    const pageMatrix = docViewer.getDocument().getPageMatrix(annotation.PageNumber);
    // Set the height & width of the canvas to match the annotation
    canvas.height = annotation.Height;
    canvas.width = annotation.Width;
    const ctx = canvas.getContext('2d');
    // Translate the Annotation to the top-left corner of the canvas, i.e., (0, 0)
    ctx.translate(-annotation.X, -annotation.Y);
    // Draw the Annotation onto the Canvas
    annotation.draw(ctx, pageMatrix);
    // Convert the Canvas to a Blob Object for Upload
    canvas.toBlob((blob) => {
        // Call your Blob Storage Upload Function
    });
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Add a disclaimer to the signature modal

Starting in WebViewer 12.2, you can add a disclaimer to the signature modal, for example, to cover confidentiality or legal terms. The disclaimer is off by default. To show it, call [UI.enableSignatureDisclaimer](https://sdk.apryse.com/api/web/UI.html#.enableSignatureDisclaimer__anchor). To hide it again, call [UI.disableSignatureDisclaimer](https://sdk.apryse.com/api/web/UI.html#.disableSignatureDisclaimer__anchor). You can also replace the default text with your own by using [UI.setTranslations](https://sdk.apryse.com/api/web/UI.html#.setTranslations__anchor).

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  // ...Config options
}).then(instance => {
  const { UI } = instance;
  UI.enableSignatureDisclaimer();
  UI.setTranslations('en', {
      'message.signatureDisclaimer': "New legal message"
  });
  UI.disableSignatureDisclaimer();
});
```

{% endcode %}

**Related links**

* [enableSignatureDisclaimer](https://sdk.apryse.com/api/web/UI.html#.enableSignatureDisclaimer)
* [disableSignatureDisclaimer](https://sdk.apryse.com/api/web/UI.html#.disableSignatureDisclaimer)
* [setTranslations](https://sdk.apryse.com/api/web/UI.html#.setTranslations)
  {% endtab %}
  {% endtabs %}

The following screenshot shows the signature modal with the default disclaimer text. If you set a custom message with `UI.setTranslations`, it replaces this text.

<figure><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2FsKWOmpnWEur4GNhHk69M%2F17fef0a6d9536b0f4a37829c4f2afc558da9642e-1008x1030.png?alt=media&amp;token=22853bcb-5888-4a4e-b832-c0f8b4d3cfc2" alt="A screenshot of the Signature Modal. The title says &#x22;Create New Signature&#x22;. The body contains an area to draw a new signature, or to alternatively type or upload a signature. Below that is a disclaimer that says &#x22;This electronic signature is representative of the signer&#x27;s intent to sign the document. By using this signature, you agree that your electronic signature is the legal equivalent of your manual signature on this document.&#x22; A &#x22;Create&#x22; button is disabled on the bottom-right of the modal."><figcaption><p>Signature modal with default disclaimer</p></figcaption></figure>

## Related blogs

* ["Signature" Signatures - Custom Signing Made Easy](https://apryse.com/blog/webviewer/create-easy-custom-signature-workflows) - 9/29/22


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/digital-signature/signature-tool.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
