Some test text!

Step 2: View a documentkeyboard_arrow_down

Step 2: View a document in Xamarin.Android

If you do not already have an existing application, create a new Visual Studio Xamarin.Android project with Single View App.

  1. In order to support all the features in DocumentActivity, we will need to add the Android permissions listed in this table. However if you would like to disable certain features and customize your document viewer, you should leave out unnecessary permissions.
Storage permission
Please note that from Android 6.0 (API 23) and up, applications need to request storage permission at runtime before accessing any files on device.
  1. Enable largeHeap and usesClearTextTraffic:

If your app is targeting Android SDK version 28 or higher, you will need to add the android:usesCleartextTraffic="true" attribute in your application tag.
  1. If you have not done so already, add the <meta-data> tag containing a reference to your license key in the AndroidManifest.xml file. Also, declare DocumentActivity in the same file. The final AndroidManifest.xml file should look something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest ...>
        <!-- Required permissions are added here -->
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
        <!-- Add multidex support, enable largeHeap, and enable usesCleartextTraffic -->
            <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
            <!-- Document viewer activity declaration-->
            <activity android:name="com.pdftron.pdf.controls.DocumentActivity"
  2. Add the following two lines at the end of the OnCreate method in MainActivity.cs:

    var config = new pdftron.PDF.Config.ViewerConfig.Builder().OpenUrlCachePath (this.CacheDir.AbsolutePath).Build();
    var intent = DocumentActivity.IntentBuilder.FromActivityClass(this, Java.Lang.Class.FromType(typeof(DocumentActivity)))
    Note that using the cache is a temporary solution and you should request runtime permissions for external storage.
  3. Build your project and deploy it to your Android Device/Emulator. You should see the viewer start up:

linkNext step

CustomizeAdd a PDFTron license key

To view a document from other sources into DocumentActivity, check out this guide.

Get the answers you need: Support


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 upcoming webinar to learn about how to collaborate on videos frame by frame directly in your browser

Save your seat