Some test text!

Setup

Contents

Prerequisites
Installation
Android
iOS

linkPrerequisites

  • PDFTron SDK >= 6.10.0
  • react-native >= 0.59.0
  • npm
  • A valid PDFTron license key. If you do not have a license key, please contact sales for a commercial license key or click here to get an evaluation key.

  • A valid integration credential. If you do not have an integration credential, please click here to get an integration credential.

linkInstallation

linkAndroid

For simplicity the following guide is based on boilerplate flutter app react-native init MyApp with git diff syntax for adding and removing lines from the boilerplate app.
  1. First, follow the official getting started guide on setting up the React Native environment, setting up the Android environment, and creating a React Native project, the following steps will assume your package ID is com.myapp (by calling react-native init MyApp).

  2. In MyApp folder, install react-native-pdftron by calling:

    npm install git+https://github.com/PDFTron/pdftron-react-native.git --save
  3. Then link the module by calling:

    react-native link react-native-pdftron
  4. In your root android/build.gradle file, add the following:

    buildscript {
        ext {
            buildToolsVersion = "28.0.3"
            minSdkVersion = 16
            compileSdkVersion = 28
            targetSdkVersion = 28
            supportLibVersion = "28.0.0"
        }
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            mavenLocal()
            google()
            jcenter()
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url "$rootDir/../node_modules/react-native/android"
            }
    +       maven {
    +           url "s3://pdftron-maven/release"
    +           credentials(AwsCredentials) {
    +               accessKey AWS_ACCESS_KEY
    +               secretKey AWS_SECRET_KEY
    +           }
    +       }
        }
    }
  5. Add the following credentials in the android/gradle.properties file. If you do not have an integration credential, please click here to get an integration credential.

    AWS_ACCESS_KEY=YOUR_ACCESS_KEY_GOES_HERE
    AWS_SECRET_KEY=YOUR_SECRET_KEY_GOES_HERE
  6. Add the following in your android/app/build.gradle file:

    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
        defaultConfig {
            applicationId "com.reactnativesample"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            versionCode 1
            versionName "1.0"
    +       multiDexEnabled true
        }
        
    +   configurations.all {
    +       resolutionStrategy.force "com.android.support:appcompat-v7:28.0.0"
    +       resolutionStrategy.force "com.android.support:support-v4:28.0.0"
    +   }
    
        ...
    }
  7. Add the following to your android/app/src/main/AndroidManifest.xml file:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.myapp">
    + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
      <application
        ...
    +   android:largeHeap="true"
    +   android:usesCleartextTraffic="true">
    
        <activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    -     android:windowSoftInputMode="adjustResize"
    +     android:windowSoftInputMode="adjustPan"
    +     android:theme="@style/CustomAppTheme">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      </application>
    </manifest>
If your app is targeting Android SDK version 28 or higher, please also set the android:usesCleartextTraffic="true" attribute in your application tag.
  1. Replace App.js with what is shown here.
  2. Finally in the root project directory, run react-native run-android.

linkiOS

For simplicity the following guide is based on boilerplate flutter app react-native init MyApp with git diff syntax for adding and removing lines from the boilerplate app.
  1. First, follow the official getting started guide on setting up the React Native environment, setting up the iOS environment, and creating a React Native project. The following steps will assume your app is created through react-native init MyApp.

  2. In MyApp folder, install react-native-pdftron by calling:

    npm install git+https://github.com/PDFTron/pdftron-react-native.git --save
  3. Link the module by calling:

    react-native link react-native-pdftron
  4. Add a Podfile in the ios folder with the following:

    An evaluation or commercial license key is required to run PDFTron. If you are evaluating the SDK and do not have a key, please obtain one, and then visit this page via the link included in the trial email. If your company has licensed PDFTron then you already received your key in an email from team@pdftron.com. See sign in for more details.
  5. In the ios folder, run pod install.

  6. If you need a close button icon, you will need to add the PNG resources to MyApp as well, i.e. ic_close_black_24px.

  7. Try building MyApp. If any error occurs, change the project settings as described here.

  8. Replace App.js with what is shown here.

  9. Finally in the root project directory, run react-native run-ios.

Get the answers you need: Support

Contents

Prerequisites
Installation
Android
iOS