Show a document in an Activity
Apryse's Android SDK ships with DocumentActivity, an all-in-one document reader and PDF editor. In addition to PDF files, it also supports viewing other file formats such as .docx, .doc, .pptx, .xlsx, .md, .cbz and various image formats. In this activity you can also read, annotate, sign, fill in PDF forms and more.
DocumentActivity extends Android's AppCompatActivity and follows Material design guidelines.

Prerequisites
Integrated Apryse into your project and added the
PDFTron.Android.ToolsNuGet package into your project.Minimum API: 21 (using AndroidX)
Compile API: 35
Recommended target API: 35
Step 1: Update AndroidManifest.xml
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.
Enable
largeHeap:
If you have not done so already, add your license in the
AndroidManifest.xmlfile, and also declareDocumentActivityin the manifest file. The finalAndroidManifest.xmlfile should look something like this:
Step 2: Launch the viewer
Launch DocumentActivity by specifiying a local file path, an HTTP/HTTPS url, or a Content Uri:
Step 3: (Optional) Customize the viewer
If you would like to customize the appearance of the viewer activity, define
PDFTronAppThemeinres/values/styles.xml:You can learn more about this in the customize the viewer's theme guide .
Also, if you would like to customize the UI components in
DocumentActivity, you can useViewerConfig.Builder. For example:For details on customizing the UI and usingViewerConfig.Builder, check out the configuration tutorial .
Last updated
Was this helpful?