Licensing

Sometimes, in order to study the system better, you want to dive into the code as fast as possible. To make this easier, Aspose.Words provides different plans for purchase or offers a Free Trial and a 30-day Temporary License for evaluation.

Free Trial or Temporary License

Aspose.Words is incredible software that developers can try before purchasing. You can easily download/install Aspose.Words for Java and Aspose.Words for Android via Java from the download page for evaluation.

The evaluation version is the same as the purchased one – the Trial version simply becomes licensed when you add a few lines of code to apply the license.

Purchased License

After purchase, you need to apply the license file or include the license file as an embedded resource. This section describes options of how this can be done, and also comments on some common questions.

Protecting Your Purchased License

After purchasing a license, you need to carefully read the information on page Protecting Your Purchased License to protect your license file. Please note that this page is available for viewing only if you have a paid license.

License Applying Options

Licenses can be applied from various locations:

  • Explicit path
  • An embedded resource
  • As a Metered License – a new licensing mechanism

Loading the License file

In Aspose.Words for Android via Java, the license can be embedded as a resource, or loaded from a stream:

  1. Put the license file at any location on /mnt/sdcard/.
  2. Create a stream that references file.
  3. Pass the stream (containing the license file) into the SetLicense method.

Java

String dataDir = Environment.getExternalStorageDirectory().getPath() + "/";

// Create a stream object containing the license file
FileInputStream fstream = new FileInputStream(dataDir + "Aspose.Email.Android.Java.lic");

// Instantiate the `License` class
License license = new License();
//Set the license through the stream object
license.setLicense(fstream);

Applying a License from an Embedded Resource. To access the license as a resource by name from an Android package file:

  1. Add the license file as a resource to your application’s res/raw folder. The license file should be visible in the res/raw folder.
  2. Access/load the license from the resource with the following code sample.

Java

License license = new License();
InputStream inputStream = getResources().openRawResource(R.raw.license);
license.setLicense(inputStream);

Apply Metered License

Aspose.Words allows developers to to apply metered key. It is a new licensing mechanism. The new licensing mechanism will be used along with existing licensing method. Those customers who want to be billed based on the usage of the API features can use the metered licensing.

Java

Metered metered = new Metered();
try
{
	// Access the setMeteredKey property and pass public and private keys as parameters
    metered.setMeteredKey(publicKey, privateKey);
	Log.i("Metered License", "Ok. Metered License has been applied successfully.");
}
catch (Exception ex)
{
    ex.printStackTrace();
    Log.e("Metered License", "Setting metered key has failed: " + ex.getMessage());
}

Changing the License File Name

The license file name does not have to be ‘Aspose.Words.Android.Java.lic’. You can rename it to anything you like and use that name when calling License.SetLicense.

Exception - Cannot find license filename

When you download a license you’ve bought, the license file is named Aspose.Words.Android.Java.lic by default. The license file is downloaded through your browser and some browsers recognize the license file as XML and append an .xml extension to the name. The downloaded file becomes Aspose.Words.Android.Java.lic.XML.

When Microsoft Windows is configured to hide extensions of known file types (unfortunately this is default in most Windows installations), the license file is listed as Aspose.Words.Android.Java.lic in Windows Explorer. It looks like the expected file name. If you call License.SetLicense and pass ‘Aspose.Words.Android.Java.lic’, you’ll see and exception because there is no such file. 

To solve the problem, rename the file to remove the invisible .xml extension. We recommend that you disable the “hide extensions” option in Microsoft Windows.

Using Multiple Aspose Products

If you use several Aspose products in an application, for example Aspose.Words and Aspose.Cells, here are a few useful tips.

  • Set the license for each Aspose product separately. Even if you have a single license file for all components, for example ‘Aspose.Total.Android.Java.lic’, you still need to call the License.SetLicense method separately for each Aspose product.
  • Use fully qualified License class name. Each Aspose product has a License class in its namespace. For example, Aspose.Words has com.aspose.words.License and Aspose.Cells has com.aspose.cells.License class. Using the fullyqualified class name allows you to avoid any confusion about which license is applied to which product.

FAQ

  1. Q: How do I apply a license in Aspose.Words for Android via Java?
    A: Create an instance of com.aspose.words.License and call setLicense with either a file path, an InputStream, or a resource ID. The call must be made once per application domain and before any other Aspose.Words classes are used. Example (from a file):

    License license = new License();
    FileInputStream stream = new FileInputStream("/mnt/sdcard/MyLicense.lic");
    license.setLicense(stream);
    
  2. Q: I get a “Cannot find license filename” exception – what is wrong?
    A: The most common cause is an extra hidden “.xml” extension added by the browser or Windows hiding extensions. Verify the actual file name on disk and rename it to remove any extra extension (e.g., Aspose.Words.Android.Java.lic). Then pass the exact name to setLicense.

  3. Q: Can I rename the license file to a custom name?
    A: Yes. The license file can have any name; just supply that exact name or path when calling license.setLicense. The API does not depend on a specific file name.

  4. Q: How do I use a metered license with Aspose.Words for Android via Java?
    A: Instantiate com.aspose.words.Metered, then call setMeteredKey with your public and private keys. This can be used in addition to the traditional XML license. Example:

    Metered metered = new Metered();
    metered.setMeteredKey(publicKey, privateKey);
    
  5. Q: Do I need to set a license for each Aspose product I use?
    A: Yes. Even if you have a single “total” license file, you must call License.SetLicense (or the equivalent for each product) for every Aspose component (e.g., Words, Cells) you use, preferably using the fully‑qualified class name to avoid ambiguity.