Getting started

keyboard_arrow_down
Running samplesTry demo in your projectDownloading PDFTronIntegrating PDFTron via GradleManually integrating PDFTronUpgradingAdding PDFTron license keyUsing ProGuardTroubleshooting integration

Fundamentals

keyboard_arrow_down
Document lockingSaving PDF documentsUnderstanding coordinates

Basics

keyboard_arrow_down
Using an ActivityUsing a FragmentUsing PDFViewCtrlViewer configConverting and viewing other document typesConverting HTML to PDF

Viewer

keyboard_arrow_down
PDFViewCtrl color modesPDFViewCtrl page view modePDFViewCtrl page presentation modeGenerating thumbnails in PDF

Features

keyboard_arrow_down
Day/Night themesUndo and redoText searchAnnotation syncingRotating PDF pagesPDFViewCtrl read onlyUsing PDFViewCtrl with minimum memory

Tools

keyboard_arrow_down
Tools overviewSetting Up ToolManagerChanging and disabling toolsIntercepting annotation handlingToolManager eventsDefault annotation propertiesTool subclasses

Annotations

keyboard_arrow_down
Deleting annotationsAnnotation styleShow/hide annotations

UI components

keyboard_arrow_down
Quick menuAnnotation toolbarAnnotation style dialogThumbnail sliderAnnotations listOutline listUser bookmarks listBookmarks dialogPage thumbnails dialogAdd page dialogRotate pages dialogView mode dialogCrop page dialogReflow

Advanced

keyboard_arrow_down
Adding a custom view to a PDF pageCustom toolCustomizing quick menuCustomizing annotation style dialog

FAQ

keyboard_arrow_down
Running project in Android StudioSystem RequirementsPDFTron full vs. standardLocalizationIcon cheat sheetRunning sample with sourceReducing size of APKEnable multidexOut of memory when rotating device multiple timesDetachCurrentThread warning

PDF Processing API

keyboard_arrow_down
What is PDFNet?Opening a documentSerializing (saving) a documentWorking with pagesWorking with Page ContentWorking with BookmarksWorking with Interactive Forms (AcroForms)PDF SecurityLow-level PDF APIError handling
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.

linkVia 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

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

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

linkFeatures:

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