Some test text!

Search
Hamburger Icon

iOS / Guides

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.

Integrate Android PDF Library using Flutter

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.

Get the Flutter source code

Prerequisites

No trial license key required.
The trial of Apryse SDK does not require a trial key. A commercial license key is required for use in a production environment. Please fill out our contact form if you do not have a valid license key.
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:

    flutter create myapp
  2. Add the following dependency to your Flutter project in myapp/pubspec.yaml:

    • If you want to use our null safe package from pub.dev:

      ```diff

      //@data {"gitDiff":true}// dependencies: flutter: sdk: flutter

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

    dependencies:
       flutter:
          sdk: flutter
    +   pdftron_flutter:
    +     git:
    +       url: git://github.com/ApryseSDK/pdftron-flutter.git
  1. Navigate to your myapp folder:

    cd myapp

    and run the following command to get the required packages:

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

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

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myapp">
    
       <!-- Required to read and write documents from device storage -->
    +  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
       <!-- Required if you want to record audio annotations -->
    +  <uses-permission android:name="android.permission.RECORD_AUDIO" />
    
       <!-- 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">
    
         <!-- 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}"/>
    
         <activity
             android:name=".MainActivity"
             android:exported="true"
             ...
             android:windowSoftInputMode="adjustResize">
    
             <!-- 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. -->
             <meta-data
               android:name="io.flutter.embedding.android.NormalTheme"
               android:resource="@style/NormalTheme"
               />
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>
         <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
         <meta-data
             android:name="flutterEmbedding"
             android:value="2" />
     </application>
    </manifest>
  4. In your android/gradle.properties file, add the following line:

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

    import androidx.annotation.NonNull
    import io.flutter.embedding.android.FlutterFragmentActivity
    import io.flutter.embedding.engine.FlutterEngine
    import io.flutter.plugins.GeneratedPluginRegistrant
    
    class MainActivity : FlutterFragmentActivity() {
        override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
            GeneratedPluginRegistrant.registerWith(flutterEngine);
        }
    }

Next step

View a document

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales