Some test text!

Loading...
Guides

Get started integrating PDFTron Flutter SDK

Welcome to PDFTron. This guide will help you integrate a free trial of the PDFTron 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 PDFTron Flutter SDK on iOS.

This guide will help you integrate a free trial of the PDFTron 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 PDFTron SDK works without a license key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
Keep your commercial license key 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:

      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/PDFTron/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="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="${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

Get the answers you need: Support

Upcoming Webinar: Customer Experience and Retaining Control: Boosting Document Automation and Efficiency in Financial Services | Sept 15, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use