Some test text!
Xamarin / Guides / Step 2: View a document
If you do not already have an existing application, create a new Visual Studio Xamarin.Android
project with Single View App
.
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.Enable largeHeap
and usesClearTextTraffic
:
<!-- Enable usesCleartextTraffic in application attributes if you are
working with HTTP files. If you are only working with HTTPS files, this is not required. -->
<application
...
android:largeHeap="true"
android:usesCleartextTraffic="false">
...
</application>
android:usesCleartextTraffic="true"
attribute in your application tag to open HTTP files in the viewer. If you are only working with HTTPS files, this is not required.<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.RECORD_AUDIO" />
<!-- Add multidex support, enable largeHeap, and enable usesCleartextTraffic.
Also enable usesCleartextTraffic in application attributes if you are
working with HTTP files. If you are only working with HTTPS files, this is not required. -->
<application
...
android:largeHeap="true"
android:usesCleartextTraffic="true">
<!-- Add license key in meta-data tag here. This should be inside the application tag. -->
<meta-data
android:name="pdftron_license_key"
android:value="INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE"/>
<!-- Document viewer activity declaration-->
<activity android:name="com.pdftron.pdf.controls.DocumentActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
android:windowSoftInputMode="adjustPan"
android:theme="@style/PDFTronAppTheme"/>
...
</application>
</manifest>
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)))
.WithUri(Android.Net.Uri.Parse("https://pdftron.s3.amazonaws.com/downloads/pdfref.pdf"))
.UsingConfig(config)
.Build();
StartActivity(intent);
Build your project and deploy it to your Android Device/Emulator. You should see the viewer start up:
Customize Add an Apryse license key
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales