Some test text!

platform
search

Add license key

Contents

Add license key in AndroidManifest.xml
Add license key directly in your code
Warning
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.

In order to automatically initialize PDFTron in your app, you'll need to add a valid license key in the AndroidManifest.xml file of your Android project. Alternatively, you can add the key by manually calling the static initialization methods. Before moving forward, please make sure you have added the PDFTron libraries to your project.

linkAdd license key in AndroidManifest.xml

The PDFTron Android SDK is auto-initialized only if there is a key defined in the AndroidManifest.xml file named pdftron_license_key. If you prefer to initialize PDFTron manually, see the next section for more information.
  1. Find your gradle.properties file in the root folder of your project and add your license key:

    PDFTRON_LICENSE_KEY=YOUR_PDFTRON_LICENSE_KEY_GOES_HERE
  2. Then, in your module's Gradle file (usually app/build.gradle), add:

    android {
        defaultConfig {
            // ...
            manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
        }
    }
  3. Add a placeholder for the license key to your AndroidManifest.xml file, inside the <application> tag:

    <application
        ...>
        
        ...
    
        <!-- Add license key in meta-data tag here -->
        <meta-data
            android:name="pdftron_license_key"
            android:value="${pdftronLicenseKey}"/>
            
    </application>

    This tag will inject a build variable containing our license key into the manifest file. You can learn more about how this works here.

    You're now ready to start using PDFTron classes! Next let's try opening a document in an activity.

linkAdd license key directly in your code

Please ensure that you do not have pdftron_license_key defined in your AndroidManifest.xml file, otherwise PDFTron will be auto-initialized using this key.

Depending on the package you are using, you will need to call different initialization methods. In your main application's or main activity's onCreate method (and before setContentView in your activity) call one of the following:

  • Demo package:

    If you are using a com.pdftron:demo dependency (i.e. using implementation "com.pdftron:demo:6.10.0" in your app/build.gradle file), make sure you are using the full version of PDFTron library and call:

    com.pdftron.demo.utils.AppUtils.initializePDFNetApplication(getApplicationContext(), "YOUR_PDFTRON_LICENSE_KEY_GOES_HERE");
    The PDFTron demo library requires the full version of PDFTron library. See PDFTron full or standard? for more details.
  • Tools package:

    If you are only using a com.pdftron:tools dependency (i.e. using implementation "com.pdftron:tools:6.10.0" and not using implementation "com.pdftron:demo:6.10.0" in your app/build.gradle file):

    com.pdftron.pdf.utils.AppUtils.initializePDFNetApplication(getApplicationContext(), "YOUR_PDFTRON_LICENSE_KEY_GOES_HERE");
  • PDFTron package:

    If your application requires greater flexibility and you are using classes in the PDFTron package directly, you can initialize using the following method instead:

    PDFNet.initialize(getApplicationContext(), R.raw.pdfnet, "YOUR_PDFTRON_LICENSE_KEY_GOES_HERE");

    If you are also using a the Tools library (i.e. com.pdftron:tools) call:

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    Please note that if you use PDFNet.initialize, you will have to set up the PDFTron library manually (for more information see the PDFTron class documentation).

You're now ready to start using PDFTron classes! Next let's try opening a document in an activity.

Get the anwsers you need: Support

Contents

Add license key in AndroidManifest.xml
Add license key directly in your code