Running sampleskeyboard_arrow_down

Running sample projects

In this document
chevron_rightVia command line
chevron_rightVia Android Studio
chevron_rightCompleteReader app
chevron_rightFeatures:
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.
If you are interested in trying out the sample activities in your application directly, please check out this article instead.

PDFTron for Android ships with two sample projects, each containing examples that you could use in your project. Both samples are included in the download package under the \samples folder. You can run any of the sample projects via command line and/or via Android Studio.

Via command line

First, add your PDFTron license key into the gradle.properties file in the root folder of the sample project of interest (i.e. \samples\CompleteReader\gradle.properties or \samples\MiscellaneousSamples\gradle.properties):

PDFTRON_LICENSE_KEY=YOUR_PDFTRON_LICENSE_KEY_GOES_HERE

Then, if you have not imported the project of interest into Android Studio, you will need to manually create a local.properties file in the root folder of the sample project of interest (i.e. \samples\CompleteReader\local.properties or \samples\MiscellaneousSamples\local.properties), and add the following to it:

sdk.dir=your_android_sdk_path
You can find this information in your Android Studio's SDK Manager window.
Before moving on, please ensure adb is in your $PATH environment variable.

To deploy via command line, simply navigate to the root folder of the sample project of interest (i.e. \samples\CompleteReader, or \samples\MiscellaneousSamples), have one device or emulator running, then run the following command:

For Windows:

.\gradlew.bat appStart

For Mac:

gradle appStart

For Mac users, if you encounter any errors, please make sure you have Homebrew and gradle installed, and that Gradle's version is above Gradle 4.1. Otherwise, do the following:

brew update && brew install gradle

Via Android Studio

First, add your PDFTron license key to the gradle.properties file in the root folder of the sample project of interest (i.e. \samples\CompleteReader\gradle.properties or \samples\MiscellaneousSamples\gradle.properties):

PDFTRON_LICENSE_KEY=YOUR_PDFTRON_LICENSE_KEY_GOES_HERE

To deploy via Android Studio, follow the steps at Run existing project in Android Studio.

CompleteReader app

Download sample APK here: CompleteReader.apk.

This app contains two document viewing and editing activities, SimpleReaderActivity and AdvancedReaderActivity.

SimpleReaderActivity is an all-in-one document reader and PDF editor. In addition to PDF files, it supports viewing other file extensions such as .docx, .doc, .pptx, .xlsx, .md, .cbz and various image formats. It allows stream conversion of these non-pdf documents to PDF format so you can view the document while conversion happens. In this activity, you can read, annotate, sign, and fill in PDF forms, and more. See the detailed list of features below.

AdvancedReaderActivity has everything in SimpleReaderActivity, plus file browsers for local and SD card files. It has an example of how you can implement lists of recent and favorite files. It also demonstrates how to use document thumbnails. In addition, it supports file merging and creating new files using styles such as lined, grid, graph, and music sheet. See the detailed list of features below.

To run the CompleteReader sample from source, check out this FAQ article.

Features:

MiscellaneousSamples app

This app showcases the functionality of the PDFTron SDK and includes the samples found on the sample code page. You can inspect its source code to learn how to use some of the main classes and features of the SDK, or just run the sample and view the results.