Integrating PDFTron via Gradlekeyboard_arrow_down

Integrating PDFTron via Gradle package manager

If you prefer to include AAR files directly in your project, you can find an alternative approach here.

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

The following are a few simple steps that will prepare your Android Studio project for your integration of PDFTron libraries into one of your own projects.

  1. Add rules to your project's root-level build.gradle file in order to include PDFNet's Maven repository. For example:
allprojects {
    ...
    repositories {
        ...
        google()
        maven {
            url "s3://pdftron-maven/release"
            credentials(AwsCredentials) {
                accessKey AWS_ACCESS_KEY
                secretKey AWS_SECRET_KEY
            }
        }
    }
}
  1. Add credentials to your project's gradle.properties file:
You will see the credentials after obtaining a license key here.

  1. In your module's Gradle file (usually app/build.gradle), add:
android {
    defaultConfig {
        ...
        vectorDrawables.useSupportLibrary = true
    }
    configurations.all {
        resolutionStrategy.force "com.android.support:appcompat-v7:27.0.2"
        resolutionStrategy.force "com.android.support:support-v4:27.0.2"
    }
}

dependencies {
    ...
    implementation "com.pdftron:pdftron:6.8.5"
    implementation "com.pdftron:tools:6.8.5"
}
  1. To use the activities shown in the CompleteReader sample project, include the following as well:
dependencies {
    ...
    implementation "com.pdftron:demo:6.8.5"
}

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.

Note: PDFTron SDK for Android is hosted on a private Maven repository in Amazon S3, so an access token is required to download it. The project only communicates with Amazon S3 in order to download PDFTron SDK for Android. Otherwise, no other communication between your environment and Amazon S3 (or any other external service) is required. If you prefer not to use Amazon S3, you can find an alternative approach here.