Get started integrating Apryse Flutter SDK

Welcome to Apryse. This guide will help you integrate a free trial of the Apryse Flutter SDK into your Flutter Project. Your free trial includes unlimited trial usage and support from solution engineers.

Android & Flutter PDF library integration

See here for the get started guide for using the Apryse Flutter SDK on iOS.

This guide will help you integrate a free trial of the Apryse SDK into your Android applications using Flutter. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

No trial license key required.

The trial of Apryse Mobile SDK does not require a trial key. A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Keep your license keys confidential.

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

Integrate

For simplicity, the following guide is based on a boilerplate Flutter app and uses Git Diff syntax to represent lines that have been added to or removed from the app. Please follow these Flutter get started guides to install, set up an editor, and create a Flutter Project if you are a first time Flutter developer

  1. Initialize the project by running the command:

sh

1flutter create myapp
  1. Add the following dependency to your Flutter project in myapp/pubspec.yaml:
    • If you want to use our null safe package from pub.dev://@data {"gitDiff":true}// dependencies: flutter: sdk: flutter

sh

1```diff
  • pdftron_flutter:
  • If you want to use our null safe package from GitHub:

shell

1dependencies:
2 flutter:
3 sdk: flutter
4+ pdftron_flutter:
5+ git:
6+ url: git://github.com/ApryseSDK/pdftron-flutter.git
  1. Navigate to your myapp folder:and run the following command to get the required packages:

sh

1cd myapp

sh

1flutter packages get
  1. Now add the following items in your myapp/android/app/build.gradle file:

Groovy

1defaultConfig {
2 applicationId "com.example.myapp"
3- minSdkVersion flutter.minSdkVersion
4+ minSdkVersion 21
5+ multiDexEnabled true
6+ manifestPlaceholders += [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
7 targetSdkVersion flutter.targetSdkVersion
8 versionCode flutterVersionCode.toInteger()
9 versionName flutterVersionName
10}
  1. In your myapp/android/app/src/main/AndroidManifest.xml file, add the following lines:

XML

1<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp">
2
3 <!-- Required to read and write documents from device storage -->
4+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
5 <!-- Required if you want to record audio annotations -->
6+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
7
8 <!-- Enable usesCleartextTraffic in application attributes if you are working with HTTP files. If you are only working with HTTPS files, this is not required.-->
9 <application ... + android:largeHeap="true" + android:usesCleartextTraffic="false">
10
11 <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
12+ <meta-data
13+ android:name="pdftron_license_key"
14+ android:value="${pdftronLicenseKey}"/>
15
16 <activity android:name=".MainActivity" android:exported="true" ... android:windowSoftInputMode="adjustResize">
17
18 <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. -->
19 <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
20 <intent-filter>
21 <action android:name="android.intent.action.MAIN"/>
22 <category android:name="android.intent.category.LAUNCHER"/>
23 </intent-filter>
24 </activity>
25 <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
26 <meta-data android:name="flutterEmbedding" android:value="2" />
27 </application>
28</manifest>
  1. In your android/gradle.properties file, add the following line:

shell

1# Add the PDFTRON_LICENSE_KEY variable here.
2# For trial purposes leave it blank.
3# For production add a valid commercial license key.
4PDFTRON_LICENSE_KEY=
  1. If you are using the DocumentView widget, change the parent class of your MainActivity file (either Kotlin or Java) to FlutterFragmentActivity.

Kotlin

1import androidx.annotation.NonNull
2import io.flutter.embedding.android.FlutterFragmentActivity
3import io.flutter.embedding.engine.FlutterEngine
4import io.flutter.plugins.GeneratedPluginRegistrant
5
6class MainActivity : FlutterFragmentActivity() {
7 override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
8 GeneratedPluginRegistrant.registerWith(flutterEngine);
9 }
10}

Next step

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales