Integrating Cordova PDF Library with Android

This project is no longer in development. If you are looking for cross-platform solution, check out React Native or Flutter. If you are looking to add to your current Cordova/Ionic project, check out the WebViewer sample.

This guide will help you integrate a free trial of the Apryse Native Plugin for Android applications using Cordova. Your free trial includes unlimited trial usage and support from solution engineers.

See here for the get started guide for using the Apryse Cordova Native Plugin on iOS.

Note: There are other approaches that can be used to integrate Apryse technology with Cordova. Please see this FAQ page to find out more about the relative strengths of each approach.

Prerequisites

The Eclipse IDE is not supported.

Setup

If you don't already have a Cordova codebase, start one. If you do, then make sure Android is added as a platform and skip to integration.

  1. Create a new Cordova project called pdfhello

sh

1cordova create pdfhello com.example.pdf pdfhello
2
3 cd pdfhello
  1. Add Android as a platform to build the Cordova application for.

sh

1cordova platform add android

Integrate Apryse Native Plugin into your Cordova Application

  1. Add the pdftron-cordova plugin in your project directory.

sh

1cordova plugin add https://github.com:PDFTron/pdftron-cordova.git
  1. Navigate to pdfhello/platforms/android and add the following line in the gradle.properties file:Key can be left empty for a trial

sh

1PDFTRON_LICENSE_KEY=INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE
  1. Navigate to pdfhello/platforms/android/app/main/ and open AndroidManifest.xml with your favorite text editor.Change the activity theme to CustomAppTheme:

XML

1-<activity android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
2+<activity android:name="MainActivity" android:theme="@style/CustomAppTheme">
  1. Navigate to pdfhello/platforms/android/app/main/com/example/pdf/ and open MainActivity.java with your favorite text editor. Change the base class for the main activity from CordovaActivity to CordovaAppCompatActivity:

Java

1-public class MainActivity extends CordovaActivity {
2+public class MainActivity extends CordovaAppCompatActivity {

Next step

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales