Some test text!

menu
Integratekeyboard_arrow_down

Integrate Android PDF Library into Cordova

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

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

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

Get the PDFTron Cordova source code

linkPrerequisites

No trial license key required.
The trial of PDFTron SDK works without a license key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
Keep your commercial license key confidential.
License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

linkSetup

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

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

    cordova platform add android

linkIntegrate PDFTron Native Plugin into your Cordova Application

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

    cordova plugin add https://github.com:PDFTron/pdftron-cordova.git
  2. Navigate to pdfhello/platforms/android and add the following line in the gradle.properties file:

    android.useAndroidX=true
    android.enableJetifier=true
    PDFTRON_LICENSE_KEY=INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE

    Key can be left empty for a trial

  3. Navigate to pdfhello/platforms/android/app/main/ and open AndroidManifest.xml with your favorite text editor.

    Change the activity theme to CustomAppTheme:

    -<activity android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
    +<activity android:name="MainActivity" android:theme="@style/CustomAppTheme">
  4. 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:

    -public class MainActivity extends CordovaActivity {
    +public class MainActivity extends CordovaAppCompatActivity {
  5. After the changes, you will need to call the following to build and run the project:

    First, in pdfhello directory call:

    cordova build android

    Then import the pdfhello/platforms/android folder into Android Studio, and run the project from Android Studio using the play button. You will see a message that says No Java files found that extend CordovaActivity. This message is okay to ignore because we're using CordovaAppCompatActivity.

    Note: When the project is first imported, Android Studio will complain about the minSdk. To resolve this, click Move minSdkVersion to build files and sync project in the error window.

linkNext step

View a document

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.