Some test text!

Quick start - view a document

This tutorial only applies to Xamarin.Android.

Supporting Sdk versions:

  • Minimum: API 16 (Using Android Support Libraries)
  • Recommended target: API 27

To try the PDFTron demo Activity in one of your own projects, here are a few simple steps to prepare your Visual Studio project.

First, make sure your project targets 8.0+:

Open the NuGet package manager by right click on your project, and click Manage NuGet Packages.... Then in Browse tab, search for PDFTron.

Install:

Then, turn on Multi-Dex:

Next, add permissions to AndroidManifest.xml file outside of the <application> tag:

<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 license key and activity declarations to AndroidManifest.xml file inside the <application> tag:

<meta-data
    android:name="pdftron_license_key"
    android:value="your_license_key_goes_here"/>


<activity android:name="com.pdftron.demo.app.SimpleReaderActivity"
    android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
    android:windowSoftInputMode="adjustPan"
    android:theme="@style/CustomAppTheme"/>

Finally, add style to Resources/values/styles.xml:

<resources>
    <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>
        <!-- Drawer -->
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <!-- Action bar -->
        <item name="actionModeBackground">?attr/colorPrimary</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
</resources>
If you are using your own theme, please don't forget to add/change the theme tag of your AndroidManifest file's corresponding activity declaration.

To open Simple Reader demo, use:

pdftron.Demo.App.SimpleReaderActivity.Open(this);

You will see:

Please note that changes for files opened from res will not be saved on disk.

To open your own file in Simple Reader demo, use:

// from internal storage
var localFile = Android.Net.Uri.FromFile(new Java.IO.File("myLocalFilePath"));
pdftron.Demo.App.SimpleReaderActivity.OpenDocument(this, localFile);

// from content uri
var contentUri = Android.Net.Uri.Parse("myContentUri");
pdftron.Demo.App.SimpleReaderActivity.OpenDocument(this, contentUri);

// from http/https
var fileLink = Android.Net.Uri.Parse("myFileLink");
pdftron.Demo.App.SimpleReaderActivity.OpenDocument(this, fileLink);

// from res
pdftron.Demo.App.SimpleReaderActivity.OpenDocument(this, Resource.Raw.my_file_res_id);