High License Initialization Time for Aspose.PDF (24.3) and Aspose.Words (23.6) in Java

I’m currently using Aspose.PDF for Java 24.3 and Aspose.Words for Java 23.6 in my application. I’ve noticed that initializing the license for both libraries takes a noticeable amount of time:

  • Aspose.PDF: ~5 seconds
  • Aspose.Words: ~3 seconds

I’m setting the license using an InputStream, as shown below:

java

license.setLicense(inputStream);

I’ve also tried setting the license using a file path, but the performance remains the same.

Is this license loading time expected?
Are there any recommended optimizations or alternative approaches to reduce the initialization time?

Any guidance would be appreciated.

@spthakare02

The initialization time you’re experiencing for the licenses of Aspose.PDF and Aspose.Words is not uncommon, especially when loading the license from a stream or file. To address this issue effectively, consider the following strategies to reduce the initialization time:

  1. Load License Once: Ensure that you set the license only once per application domain. Repeated calls to set the license can introduce unnecessary overhead.

  2. Use Embedded Resources: If feasible, include the license file as an embedded resource in your application. This approach can speed up the loading process by eliminating file system access.

  3. Profile Your Application: Utilize profiling tools to identify any other bottlenecks in your application that may be contributing to the perceived delay.

  4. Check File System Performance: If loading the license from a file, verify that the file system is not causing delays. For instance, network drives or slow disks can significantly impact performance.

  5. Update Libraries: Ensure you are using the latest versions of the libraries, as performance improvements are often included in updates.

Here’s a simple code snippet to set the license from an embedded resource:

License license = new License();
try {
    license.setLicense(getClass().getResourceAsStream("/Aspose.Words.lic"));
    System.out.println("License set successfully.");
} catch (Exception e) {
    System.out.println("Error setting license: " + e.getMessage());
}

Please implement these suggestions and let me know if they help improve the initialization time. If you have any further questions or need additional assistance, feel free to reach out!

The license file content is already loaded into the InputStream, so the delay occurs specifically during the license.setLicense() call.
I’m only setting the license once at the start of the application, but I’d still like to know if this amount of time for setting the license is expected.

@spthakare02

The license loading time has been improved in the higher versions of the API. Also, it depends upon the environment e.g. JDK Version and application types. We request you please try with the latest version of the APIs and if you still notice any delays or unexpected loading time, please let us know by sharing your environment details with us. We will further proceed accordingly.