Some test text!
Android / Guides / Open a document
You have a few options to open a document such as with an activity, fragment, or view. A diagram of the overall view hierarchy can be found here: View hierarchy.
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.

com.pdftron:tools package into your project.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 set android:name in the <application> tag to MultiDexApplication:
<!-- Include existing attributes in application -->
<application
android:name="androidx.multidex.MultiDexApplication"
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"?>
<!-- Include existing attributes in application -->
<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 -->
<!-- Include existing attributes in application -->
<application
android:name="androidx.multidex.MultiDexApplication"
android:largeHeap="true"
android:usesCleartextTraffic="false">
<!-- Add license key in meta-data tag here. This should be inside the application tag. -->
<meta-data
android:name="pdftron_license_key"
android:value="${pdftronLicenseKey}"/>
<!-- 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>Launch DocumentActivity by specifiying a local file path, an HTTP/HTTPS url, or a Content Uri:
import android.net.Uri;
import java.io.File;
import com.pdftron.pdf.controls.DocumentActivity;
// Set the cache location using the config to store the cache file
ViewerConfig config = new ViewerConfig.Builder().openUrlCachePath(this.getCacheDir().getAbsolutePath()).build();
// from internal storage
final Uri uri = Uri.fromFile(new File("myLocalFilePath"));
// from content uri
final Uri uri = Uri.parse("myContentUri");
// from http/https
final Uri uri = Uri.parse("myFileLink");
// from assets
final Uri uri = Uri.parse("file:///android_asset/my_file.pdf");
// intent builder
Intent intent = DocumentActivity.IntentBuilder.fromActivityClass(this, DocumentActivity.class)
.withUri(uri)
.usingConfig(config)
.usingTheme(R.style.PDFTronAppTheme)
.build();
startActivity(intent);If you would like to customize the appearance of the viewer activity, define PDFTronAppTheme in res/values/styles.xml:
<style name="PDFTronAppTheme" parent="PDFTronAppThemeBase">
<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>
</style>You can learn more about this in the customize the viewer's theme guide .
DocumentActivity uses the AppCompat theme for material colors. Make sure that the value of android:theme in your activity tag also extends the AppCompat theme.Also, if you would like to customize the UI components in DocumentActivity, you can use ViewerConfig.Builder. For example:
import com.pdftron.pdf.config.ViewerConfig;
ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
.fullscreenModeEnabled(true)
.multiTabEnabled(true)
.documentEditingEnabled(true)
.longPressQuickMenuEnabled(true)
.toolbarTitle("Simple Reader")
.showSearchView(true)
.build();For details on customizing the UI and using ViewerConfig.Builder, check out the configuration tutorial .
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales