> 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/get-started/readme/cordova.md).

# Integrate WebViewer JavaScript PDF Viewer & Editor into a Cordova App

Learn how to integrate WebViewer Document Viewer & Editor into a Cordova app with this step-by-step guide. Download a sample on GitHub & get started easily. The Apryse Web SDK streamlines secure, serv

This guide will show you how to integrate [WebViewer Document Viewer & Editor](https://apryse.com/products/webviewer) into a Cordova application.

You can also download a ready-to-go sample on [GitHub](https://github.com/ApryseSDK/webviewer-cordova-sample/).

## Prerequisites

Prior to starting, you should have already installed [Node](https://nodejs.org/) and [npm](https://www.npmjs.com/).

* [Cordova CLI](https://cordova.apache.org/docs/en/latest/guide/cli/index.html)
* Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="WEB\_VIEWER" variant="full" %}

## Get Started with the Sample

### 1. Clone the Sample

Clone the `webviewer-cordova-sample` repository:

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

```sh
git clone https://github.com/ApryseSDK/webviewer-cordova-sample.git
```

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

Enter the directory and run npm install:

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

```sh
cd webviewer-cordova-sample
npm install
```

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

This will automatically download and extract the Apryse WebViewer Package.

### 2. Run the sample

Run the application by executing:

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

```sh
npm start
```

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

If your build fails, use the following command to see a list of requirements for your added platforms:

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

```sh
cordova requirements
```

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

### 3. Usage

To call more WebViewer APIs, open `/www/js/index.js` in your favorite text editor and add the API calls to the callback for the WebViewer instantiation:

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

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  path: "js/lib",
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>', // sign up to get a key at https://dev.apryse.com
  webviewerServerURL: 'https://demo.apryse.com/', // Make sure to change this option to point to your own server in production
  initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf',
  enableAnnotations: true,
  disabledElements: [
    'menuButton'
  ]
}, document.getElementById('viewer'))
  .then(function(instance) {
    const { documentViewer, annotationManager, Annotations, Tools } = instance.Core;

    // See https://docs.apryse.com/web/guides/ for more info.
    documentViewer.addEventListener('documentLoaded', function() {
      // call methods relating to the loaded document
    });
  });
</code></pre>

{% endtab %}

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

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  path: "js/lib",
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>', // sign up to get a key at https://dev.apryse.com
  pdftronServer: 'https://demo.apryse.com/', // Make sure to change this option to point to your own server in production
  initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf',
  enableAnnotations: true,
  disabledElements: [
    'menuButton'
  ]
}, document.getElementById('viewer'))
  .then(function(instance) {
    const docViewer = instance.docViewer;
    const annotManager = instance.annotManager;
    // call methods from instance, docViewer and annotManager as needed.
    // you can also access major namespaces from the instance as follows:
    // const Tools = instance.Tools;
    // const Annotations = instance.Annotations;

    // See https://docs.apryse.com/web/guides/ for more info.
    docViewer.on('documentLoaded', function() {
      // call methods relating to the loaded document
    });
  });
</code></pre>

{% endtab %}
{% endtabs %}

For example, if you want to change the theme of the WebViewer to dark mode, you would add the following:

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

```js
instance.UI.setTheme('dark');
```

{% endcode %}
{% endtab %}

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

```js
instance.setTheme('dark');
```

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

Execute `npm start` again and the theme of the viewer will change.

## Next step

<a href="/web/what-is-webviewer/usage.md" class="button primary">Usage</a><a href="/web/get-started/guides.md" class="button primary">Guides</a><a href="/web/get-started/samples.md" class="button primary">Samples</a><a href="https://sdk.apryse.com/api/web/index.html" class="button primary">API docs</a>


---

# 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/get-started/readme/cordova.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.
