Add license keys

The Apryse 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 Apryse libraries to your project.

No trial license key required.

The trial of Apryse Mobile SDK does not require a trial key. A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

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

Auto-initialize by adding a license key in AndroidManifest.xml

The Apryse 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 Apryse 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:

sh

1PDFTRON_LICENSE_KEY=INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE
  1. Then in your module's build.gradle file (usually located at app/build.gradle) add:

Groovy

1android {
2 defaultConfig {
3 // ...
4 manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
5 }
6}
  1. Add a placeholder for the license key to your project's AndroidManifest.xml file, inside the <application> tag:This tag will inject a build variable containing your license key into the manifest file.Next try opening a document in an activity.

XML

1<application ...>
2
3 <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
4 <meta-data android:name="pdftron_license_key" android:value="${pdftronLicenseKey}"/>
5
6</application>

Disable 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:

Groovy

1<provider
2 xmlns:tools="http://schemas.android.com/tools"
3 android:name="com.pdftron.pdfnet.PDFNetInitializer"
4 android:authorities="${applicationId}.pdftron-pdfnet"
5 tools:node="remove" />
6
7
8<provider
9 xmlns:tools="http://schemas.android.com/tools"
10 android:name="com.pdftron.pdf.utils.PDFTronToolsInitializer"
11 android:authorities="${applicationId}.pdftron-tools"
12 tools:node="remove" />

Manually 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 Apryse 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:

  • Tools package:If you are using com.pdftron:tools dependency (i.e. using implementation "com.pdftron:tools:11.0.0" in your app/build.gradle file):
1com.pdftron.pdf.utils.AppUtils.initializePDFNetApplication(getApplicationContext(), "Insert commercial license key here after purchase");
  • Apryse package:If your application requires greater flexibility and you are using classes in the Apryse package directly, you can initialize using the following method instead:If you are also using a the Tools library (i.e. com.pdftron:tools) call:Please note that if you use PDFNet.initialize, you will have to set up the Apryse library manually (for more information see the Apryse class documentation).
1PDFNet.initialize(getApplicationContext(), R.raw.pdfnet, "Insert commercial license key here after purchase");
1AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

Next try opening a document in an activity.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales