Some test text!

menu
search
Add a license keykeyboard_arrow_down

Add license key

The PDFTron library is automatically initialized if you have added a valid license key to your project's AndroidManifest.xml file. 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.

For trial purposes PDFTron is available without the need for a license key, however a valid license key is required to use PDFTron in a production app. If you do not have a valid license key, please contact sales for a commercial license key.

Your license key is confidential. Please make sure that it is not publicly available (e.g. in your public GitHub).

linkAuto-initialize by adding a 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=INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE
  2. Then in your module's build.gradle file (usually located at app/build.gradle) add:

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

    <application
        ...>
    
        <!-- 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}"/>
            
    </application>

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

    Next try opening a document in an activity.

linkDisable auto-initialization

It's also possible to disable auto-initialization altogether by adding the following to the <application> tag in your project's AndroidManifest.xml file:

<provider
    xmlns:tools="http://schemas.android.com/tools"
    android:name="com.pdftron.pdfnet.PDFNetInitializer"
    android:authorities="${applicationId}.pdftron-pdfnet"
    tools:node="remove" />


<provider
    xmlns:tools="http://schemas.android.com/tools"
    android:name="com.pdftron.pdf.utils.PDFTronToolsInitializer"
    android:authorities="${applicationId}.pdftron-tools"
    tools:node="remove" />


<provider
    xmlns:tools="http://schemas.android.com/tools"
    android:name="com.pdftron.demo.utils.PDFTronDemoInitializer"
    android:authorities="${applicationId}.pdftron-demo"
    tools:node="remove" />

linkManually initialize by adding a 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:7.0.2" 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(), "Insert commercial license key here after purchase");
    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:7.0.2" and not using implementation "com.pdftron:demo:7.0.2" in your app/build.gradle file):

    com.pdftron.pdf.utils.AppUtils.initializePDFNetApplication(getApplicationContext(), "Insert commercial license key here after purchase");
  • 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, "Insert commercial license key here after purchase");

    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).

Next try opening a document in an activity.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn More
close