Some test text!

menu
1. Integratekeyboard_arrow_down

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.

Gradle 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.
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

Create a new project on Android Studio called myApp.

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

linkIntegrate PDFTron SDK into your Android application

  1. Open the build.gradle file in your project's root directory:

    Edit it to include the following inside the allprojects.repositories section to include PDFTron's Maven repository:

    allprojects {
        repositories {
            // ... Anything else you already had
            google()
            maven {
                url "https://pdftron-maven.s3.amazonaws.com/release"
            }
            // *****Optionally Include if you are using the demo library*****
            maven {
                url "https://jitpack.io"
            }
            // ***************************************************
        }
    }
    Make sure you have not added the above inside the buildscript section accidentally.
    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.
  2. Open the build.gradle file in your app module's directory:

    Edit it to add a dependency for the full version of PDFTron:

    android {
        defaultConfig {
            // ... Anything that was already here
            multiDexEnabled true
            vectorDrawables.useSupportLibrary = true
            manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
        }
    }
    
    dependencies {
        // ... Anything that was already here
        implementation "com.pdftron:pdftron:7.1.4"
        implementation "com.pdftron:tools:7.1.4"
    
        implementation 'androidx.multidex:multidex:2.0.1'
    
        // ***** Optionally include the demo library ****
        implementation "com.pdftron:demo:7.1.4"
        // **********************************************
    }
    The next part of this guide will use DocumentActivity to open and view a document which requires the full version of PDFTron SDK. The standard version has lighter set of features to reduce the size of the APK.You can find out more about the differences between the two versions here. If you would like to use the standard version instead, please take a look at this guide
  3. 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=
  4. 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
  5. Open your AndroidManifest.xml file and add a <metadata> tag inside the <application> tag to be a placeholder for the license key:

    <application
    ... (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>

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.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close