Manually integrating PDFTronkeyboard_arrow_down

Manually integrating PDFTron

A demo license key or a commercial license key is required to proceed. If you have not yet received a license key, please obtain a license key here before continuing to read this documentation.

Besides integrating via gradle Maven package manager, you can also integrate manually by copying the required aar files to your project. This is typically done in order to try integrating custom builds or nightly builds containing the latest hot fixes into your application.

Android Studio is required in order to include PDFNet in your app. The Eclipse IDE is not supported.

Supported SDK versions:

  • Minimum: API 16 (using Android Support Libraries)
  • Recommended target: API 27

To integrate PDFTron libraries into one of your own projects, here are a few simple steps to prepare your Android Studio project.

  1. Extract your PDFNetAndroid library zipped bundle.
  2. Copy either the file lib/full/pdftron.aar or the file lib/standard/pdftron.aar directly into your project's libs directory (usually app/libs) without the folder structure. You can read about the differences between the two versions here.
  3. Copy the files lib/floatingactionbutton.aar, lib/pagecropper.aar, and lib/tools.aar directly into your project's libs directory.
  4. (Optional) Copy the file lib/demo.aar directly into your project's libs directory.

Now, your libs folder should look like this:

  1. Navigate back to the project's root folder. Add the following to your project's root-level build.gradle file's repositories section. For example:
buildscript {
    repositories {
        ...
        mavenCentral()
    }
    dependencies {
        ...
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
    }
}
  1. Specify flatDir in your root-level build.gradle:
allprojects {
    repositories {
        ...
        flatDir {
            dirs 'libs'
        }
    }
}

Alternatively, you can add the following to the dependencies section of your module's Gradle file (usually app/build.gradle):

dependencies {
    repositories {
        ...
        flatDir {
            dirs 'libs'
        }
    }
    ...
}
  1. Add PDFNet to your project as a dependency by adding the following to your module's Gradle file (usually app/build.gradle):
dependencies {
    ...
    implementation "com.pdftron:pdftron@aar"
    implementation "com.pdftron:tools@aar"
    implementation "com.pdftron:floatingactionbutton@aar"
    implementation "com.pdftron:pagecropper@aar"

    implementation "com.android.support:support-v4:27.0.2"
    implementation "com.android.support:appcompat-v7:27.0.2"
    implementation "com.android.support:recyclerview-v7:27.0.2"
    implementation "com.android.support:design:27.0.2"
    implementation "com.android.support.constraint:constraint-layout:1.1.2"
    implementation "android.arch.lifecycle:extensions:1.0.0"
    implementation "com.google.code.gson:gson:2.8.0"
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}

If you added demo.aar, then also add:

dependencies {
    ...
    implementation "com.pdftron:demo@aar"
    implementation 'com.facebook.fresco:fresco:1.2.0'
}

You are set to go! Now, it is time to add a PDFTron license key to your application and open a document in an Activity.