Some test text!

Loading...
Guides
How do I integrate the PDFTron libraries from source?

How to integrate the PDFTron libraries from source

The source code for the Tools and Demo libraries can be integrated into your Android app and further customized to meet your needs.

Integrate PDFTron libraries from source

Prerequisites

  • An existing Android Studio project running in the latest version of Android Studio
  • Minimum API: 16 (using AndroidX)
  • Compile API: 30
  • Recommended target API: 30
  • Downloaded the PDFTron Android SDK:

This guide will help you integrate the Tools and Demo libraries with your Android Studio project.

  1. Add the following lines in your project's root-level build.gradle file.

//@data {"ga":2207043341}// allprojects { repositories { // ... flatDir { dirs '../libs' } } }

// ...
ext.mySupportVersion = "1.2.0"
ext.myBuildToolsVersion = "29.0.2"
ext.myMinSdkVersion = 16
ext.myTargetSdkVersion = 30
ext.myCompileSdkVersion = 30

ext.pdfnetGroup = { dependencyHandler ->
    delegate = dependencyHandler

    implementation "com.pdftron:pdftron@aar"
}

ext.supportLibGroup = { dependencyHandler ->
    delegate = dependencyHandler

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:$ext.mySupportVersion'
    implementation 'androidx.recyclerview:recyclerview:$ext.mySupportVersion'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation "androidx.preference:preference:1.1.0"

    implementation "commons-io:commons-io:2.4"
    implementation "org.apache.commons:commons-lang3:3.5"
    implementation "com.google.code.gson:gson:2.8.0"
    implementation "io.reactivex.rxjava2:rxjava:2.2.2"
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    implementation "com.github.clans:fab:1.6.4"
    implementation "com.edmodo:cropper:2.0.0"
    implementation "com.squareup.picasso:picasso:2.71828"
    implementation "org.ccil.cowan.tagsoup:tagsoup:1.2.1"
}
```
  1. Create a new folder named libs in your project's root directory, then copy the following files from the SDK package to this folder:

  2. Open your project in Android Studio and go to File > New > Import Module...android_studio_welcome image

    Individually import the lib\src\PDFViewCtrlTools and lib\src\pdfnet-demo-utils library modules from the SDK package into your project.

  3. Finally, add the MultiDex and PDFTron library dependencies to your app by adding the following to your app's module level build.gradle file:

//@data {"ga":8306758630}// android { defaultConfig { // ... multiDexEnabled true vectorDrawables.useSupportLibrary = true } }

dependencies {
    // ...
    pdfnetGroup dependencies
    supportLibGroup dependencies
    
    implementation project(':pdfnet-demo-utils')
    implementation project(':PDFViewCtrlTools')
    implementation 'androidx.multidex:multidex:2.0.1'
}

```

Your project is now running PDFTron from source and you can start modifying the PDFTron Android libraries in your project.

Next Steps

Get the answers you need: Support

UPCOMING WEBINAR: Live tech update and run-through. October 21 @ 11am PDT