Some test text!

Show a document in an Activity

DocumentActivity requires the full version of the PDFTron library. See PDFTron full or standard?

PDFTron ships with DocumentActivity which is an all-in-one document reader and PDF editor. In addition to PDF files, it also supports viewing of 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, fill in PDF forms and more. See detailed features list here.

DocumentActivity extends Android's AppCompatActivity and follows Material design guidelines.

Please note that DocumentActivity requires the com.pdftron:tools package.

Here are a few simple steps to get started with DocumentActivity.

  1. First add the Android permissions you'll need for certain DocumentActivity features. You can learn more about permissions here.

    • If you need storage permission for accessing local documents, add the following permission to AndroidManifest.xml in the <manifest> tag (outside the <application> tag):

      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      Storage permission
      Please note that from Android 6.0, API 23, and up, application needs to request storage permission at runtime before accessing any files on device.
    • If you need internet permission for downloading online documents, add the following permission to AndroidManifest.xml in the <manifest> tag (outside the <application> tag):

      <uses-permission android:name="android.permission.INTERNET"/>
    • If you have sound annotation creation tool enabled, add the following permission to AndroidManifest.xml in the <manifest> tag (outside the <application> tag):

      <uses-permission android:name="android.permission.RECORD_AUDIO" />
  1. Add the following to AndroidManifest.xml:

        <activity android:name="com.pdftron.pdf.controls.DocumentActivity"
    If your app is targeting Android SDK version 28 or higher, please also set the android:usesCleartextTraffic="true" attribute in your application tag.
  2. If you would like to customize the appearance of the viewer activity, define CustomAppTheme in res/values/styles.xml:

    <style name="CustomAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="colorPrimary">@color/app_color_primary_day</item>
        <item name="colorPrimaryDark">@color/app_color_primary_dark_day</item>
        <item name="colorAccent">@color/app_color_accent</item>
        <!-- Action bar -->
        <item name="actionModeBackground">?attr/colorPrimary</item>
        <item name="windowActionModeOverlay">true</item>

    Alternatively, if you cannot use NoActionBar as a base theme:

    DocumentActivity extends AppCompatActivity and uses AppCompat Toolbar. It is important that you define a Theme.AppCompat theme for CustomAppTheme. The recommended theme is Theme.AppCompat.*.NoActionBar. Other custom themes can also be used, however be sure to disable the action bar manually:

    <style name="CustomAppTheme" parent="Theme.AppCompat.*">
        <!-- Action bar -->
        <item name="windowActionModeOverlay">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
  3. Also, if you would like to customize the UI components in DocumentActivity, you can use ViewerConfig.Builder. For example:

    For details on customizing the UI interface and using ViewerConfig.Builder, check out the configuration tutorial.

  4. Lastly, launch the activity from anywhere in your application: