Free trial

Pick a framework to get started


Get Started


Learn more


Common use cases


Open a document


Save a document




UI Customization














PDF.js Express REST API


Integrating Cordova with PDF.js Express

This guide will help you integrate a free trial of PDF.js Express into Cordova applications on the browser. It will help you clone the Cordova sample repository, walk through the project structure, and show you how to call other WebViewer APIs. Your free trial includes unlimited trial usage and support from solution engineers.

Get the Cordova sample source code here


Node.js is not required for PDF.js Express
PDF.js Express does not require Node, npm, or node_modules. It is only recommended to run the samples.
  • Cordova CLI

    npm install -g cordova

    You may have to restart your Command Prompt to access Cordova commands.

No trial license key required.
The trial of PDF.js Express SDK works without a license key. A commercial license key is required for use in a production environment. Please purchase a license key if you do not have one.

Initial setup

  1. Clone the pdfjs-express-cordova-sample repository:

    git clone
  2. Enter the directory and run npm install:

    cd pdfjs-express-cordova-sample
    npm install

    This will automatically download and extract the PDF.js Express WebViewer Package.

You are now ready to run the sample or use more PDF.js Express WebViewer APIs.

Sample overview

After initial setup, the pdfjs-express-cordova-sample directory should be laid out like this:

├── package.json
├── package-lock.json
├── node_modules
│   ├── ...
├── hooks
│   ├── ...
├── res
│   ├── ...
├── platforms
│   └── browser
|       ├── ...
└── www
    ├── index.html
    ├── js
    |   ├── lib
    |   |   ├── ...
    |   └── index.js
    ├── css
    |   └── index.css
    └── img
        └── logo.png

Notable files and directories include:

File/Folder Description
LICENSE Lists the copyright and license information.
package.json Lists the manifest of the project and contains the author/version metadata.
platforms Contains the platform specific directories and files required to run the project. The npm install will add the browser platform by default.
www Contains all the assets such as the main HTML page index.html, the PDF.js Express libraries (in /js/lib/) as well as the JavaScript files that are used for the sample.

www/js/index.js instantiates the WebViewer in the viewer element outlined by index.html. It is also where the WebViewer API calls are placed.

Run the sample

  1. Run the application by executing:

    npm start

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

    cordova requirements

    Your app should look like this:

    Cordova WebViewer Sample

Use more WebViewer APIs

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:

  path: "js/lib",
  pdftronServer: '', // Make sure to change this option to point to your own server in production
  initialDoc: '',
  enableAnnotations: true,
  disabledElements: [
}, document.getElementById('viewer'))
  .then((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 for more info.
    docViewer.on('documentLoaded', () => {
      // call methods relating to the loaded document

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


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

Cordova Sample Dark

Next step

Guides Samples API docs