Some test text!

menu

Get started integrating PDFTron Android SDK

Welcome to PDFTron. This guide will help you integrate a free trial of PDFTron Android SDK into your Android Studio projects. You can either integrate PDFTron packages automatically using Gradle, or install them manually using .aar files by downloading the SDK. Pick whichever your option you prefer, but integrating with Gradle is the recommended approach. Your free trial includes unlimited trial usage and support from solution engineers.

Manual Integration

linkPrerequisites

  • Android Studio
  • Project specifications:

    • Minimum API: 16 (using AndroidX)
    • Compile API: 29
    • Recommended target API: 29
    • If your app is using AndroidX you will also need to add android.useAndroidX=true and android.useAndroidX=true in your gradle.properties file. You can learn more about this here.
  • PDFTron Android SDK
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

  1. Extract the folder from the .zip file.

    This article will assume that the path into the extracted PDFNetAndroid library bundle is called PDFTRON_BASE

    PDFTRON_BASE=path/to/your/extraction/folder/PDFNetAndroid/
  2. Create a new project on Android Studio called myApp. Find out the path to the app/libs folder. If the libs folder does not exist, create one in the module (for example, myApp/app/libs).

    For the purposes of this guide, you can start with an Empty Activity.

linkIntegrate PDFTron SDK into your Android application

  1. Copy the full version of PDFTron SDK from PDFTRON_BASE/lib/full/pdftron.aar into your app/libs directory.
  2. Copy all of the following files into your app/libs directory:

    • PDFTRON_BASE/lib/pagecropper.aar
    • PDFTRON_BASE/lib/tools.aar
    • (Optional)PDFTRON_BASE/lib/demo.aar

    You can learn more about the different packages here.

    Now, your app/libs folder should look like this:

    app
    ├── ...
    └── libs
        ├── pdftron.aar
        ├── pagecropper.aar
        ├── tools.aar
        └── (Optional) demo.aar
  3. Open the build.gradle file in your project's root directory:

    Edit it to include the following inside the allprojects.repositories section:

    allprojects {
        repositories {
            // ... Anything else you already had
            flatDir {
                dirs 'libs'
            }
    
            // *****Optionally Include if you added demo.arr*****
            maven {
                url "https://jitpack.io"
            }
            // ***************************************************
        }
    }
    Make sure you haven't added the above inside the buildscript section accidentally.
  4. Open the build.gradle file in your app module's directory:

    Edit it to include the following inside the android.defaultConfig section:

    android {
        defaultConfig {
            // ... Anything else you already had
            multiDexEnabled true
            vectorDrawables.useSupportLibrary = true
            manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
        }
    }

    Also edit the dependencies section and include:

    dependencies {
        // ... Anything else you had here before
    
        implementation "com.pdftron:pdftron@aar"
        implementation "com.pdftron:tools@aar"
    
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.appcompat:appcompat:1.0.0'
        implementation 'androidx.recyclerview:recyclerview:1.0.0'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        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 "jp.wasabeef:richeditor-android:1.2.2"
    
        implementation 'androidx.multidex:multidex:2.0.1'
    
        // *****Optionally Include if you added demo.arr*****
        implementation "com.pdftron:demo@aar"
        implementation 'com.facebook.fresco:fresco:1.2.0'
        implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50'
        implementation "androidx.room:room-runtime:2.1.0"
        annotationProcessor "androidx.room:room-compiler:2.1.0"
        implementation "androidx.room:room-rxjava2:2.1.0"
        // ***************************************************
    }
  5. In your project's root directory, find the gradle.properties file. Copy the following line to it:

    # Add the PDFTRON_LICENSE_KEY variable here. 
    # For trial purposes leave it blank.
    # For production add a valid commercial license key.
    PDFTRON_LICENSE_KEY=
  6. Also in your gradle.properties file, add the following AndroidX flags if they do not already exist:

    # AndroidX package structure to make it clearer which packages are bundled with the
    # Android operating system, and which are packaged with your app's APK
    # https://developer.android.com/topic/libraries/support-library/androidx-rn
    android.useAndroidX=true
    # Automatically convert third-party libraries to use AndroidX
    android.enableJetifier=true
  7. Open your AndroidManifest.xml file and add a <metadata> tag inside the <application> tag to be a placeholder for the license key:

    <application
    ... (existing attributes)
    >
    
    <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
    <meta-data
        android:name="pdftron_license_key"
        android:value="${pdftronLicenseKey}"/>
        
    </application>

linkSDK package overview

PDFTron for Android contains the following key files and folders:

File/Folder NameDescription
docsContains the PDFTron Android API reference documentation
libContains the PDFTron AAR libraries and the source files to the open-source UI
- /full: Contains full version of pdftron.aar
- /standard: Contains standard version of pdftron.aar
- /src: Contains source code for tools.aar, demo.aar, pdftron-collab.aar and pdftron-collab-wvs.aar
samplesContains the Java and Kotlin sample projects: Showcase, CompleteReader, and MiscellaneousSamples
legal.txtLegal and copyright information
license.pdfPDFTron Software License agreement

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.