> 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/verify-pdf.md).

# Verify a signature using JavaScript

We offer a higher-level document-based API for verifying signatures, as well as a lower-level per-signature API. Page includes code samples.

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

*These 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 %}

{% hint style="warning" %}
Make sure you have [Full API enabled in WebViewer.](/web/what-is-webviewer/full-api.md)
{% endhint %}

We offer a higher-level document-based API for verifying signatures, as well as a lower-level per-signature API.

The simple document API has the following possible return values:

1. PDFDoc.SignaturesVerificationStatus.e\_unsigned: document has no signed signature fields.
2. PDFDoc.SignaturesVerificationStatus.e\_failure: hard failure in verification on at least one signature. This does not include trust issues, because those are flaky due to being network/config-related.
3. PDFDoc.SignaturesVerificationStatus.e\_untrusted: could not verify trust for at least one signature. This code can often be avoided by changing your VerificationOptions (add trusted certificates, enable a different revocation checking mode, etc.).
4. PDFDoc.SignaturesVerificationStatus.e\_unsupported: at least one signature contains features not supported in the current version of the SDK. Please contact us if these features are important to you.
5. PDFDoc.SignaturesVerificationStatus.e\_verified: all signed signatures in document verified. Unsigned signatures get skipped. Parts of the document may be unsigned by any signature.

For further verification-related information, the detailed API, which returns a VerificationResult and is demonstrated in the full code samples, can be used. For example, it is possible to call GetUnsupportedFeatures on VerificationResult to check which unsupported features were encountered (requires verification using 'detailed' APIs). It is also possible to retrieve a DigitalSignatureField object from the VerificationResult for further non-verification-related information. For example, if you would like to make sure that the document is entirely covered by signatures, or to look at a previous revision, the function GetByteRanges is available on DigitalSignatureField for this purpose.

To verify all cryptographic digital signatures in a document using the simple API:

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

```js
WebViewer({
  fullAPI: true,
  // Other init options
}).then(instance => {
  const { PDFNet, documentViewer } = instance.Core;

  documentViewer.addEventListener('documentLoaded', async () => {
    await PDFNet.initialize();
    const doc = await documentViewer.getDocument().getPDFDoc();

    // Run PDFNet methods with memory management
    await PDFNet.runWithCleanup(async () => {

      // lock the document before a read operation
      // runWithCleanup will auto unlock when complete
      doc.lockRead();

      const opts = await PDFNet.VerificationOptions.create(PDFNet.VerificationOptions.SecurityLevel.e_compatibility_and_archiving);

      // Add trust root to store of trusted certificates contained in VerificationOptions.
      await opts.addTrustedCertificateFromURL(public_key_file_url);

      const result = await doc.verifySignedDigitalSignatures(opts);
    });
  })
})
```

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

[Digital signatures](/web/get-started/samples/digitalsignaturestest.md) Full code sample which demonstrates using the digital signature API to digitally sign, certify, and/or verify PDF documents.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
