Got NullPointerException while processing XPS document on Windows if added Aspose libraries (19.10) are located in the path which contains spaces

We are from Nuix who is also one of the Aspose customers.
We encountered the issue as described in the title and it is easy to reproduce (the version we are using is 19.10 pdf). We attached a normal XPS (41.2 KB)

  1. Create a fresh project from IDEA
  2. Create a class and its main method contains following code:

LoadOptions options = new XpsLoadOptions();
IDocument doc = new Document((InputStream)(new FileInputStream(new File(“C:\test.xps”))), options);
catch(Exception e)

  1. Open IDEA’s “Project Structure” and in “Libraries”, add the folder that contains the Aspose libraries. The folder path MUST contain space, for example, “C:\Programs Files\Aspose 19.10\lib”

  2. Run the program and you will get error:
    Exception in thread “main” java.lang.ExceptionInInitializerError
    at com.aspose.pdf.l32y.lf(Unknown Source)
    at com.aspose.pdf.l32y.lI(Unknown Source)
    at com.aspose.pdf.ADocument.lI(Unknown Source)
    at com.aspose.pdf.ADocument.(Unknown Source)
    at com.aspose.pdf.Document.(Unknown Source)
    at TestAspose.main(
    Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at Source)
    … 6 more
    Caused by: java.lang.NullPointerException
    at Source)
    … 7 more


As it is always recommended to use latest version and support is provided on its basis, we have tested the scenario with Aspose.PDF for Java 20.6 and noticed following Exception:

Supplied XPS file or stream is corrupt and cannot be parsed!

We have logged an issue as PDFJAVA-39536 in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

This xps is not corrupted. Could you use “XPS VIewer” on WIndows to open it? I can do it on my local machine.
We have no plan of upgrading to 20.6. Please redo the test in 19.10.
We already nailed down the culprit. It is because inside Aspose library it handles the path which contains space not properly. We attached out debug screenshot. As you can see, the Aspose is trying to load aspose-pdf library from the path string which contains %20 then this path will fail the runtime. We don’t know how Apsose finds its dependencies. But definitely it is a bug in 19.10 since if we move the Aspose libraries to another folder which doesn’t contain the space in its path, the code works fine then.Please have a look at the debug screenshot.
Jietu20200703-113813.jpg (836.2 KB)


You are right about the file is not corrupted and can be viewed in XPS Viewer. However, API is raising an excpetion while loading the document which is why we have logged an issue.

We were unable to notice this issue in our environment using both 19.10 and 20.6 version of the API. The libraries were put on the path where spaces were present. Would you please try to test the scenario on another machine and share the results with us. We will further proceed to assist you accordingly.

It has nothing to do with my Windows environment. I create a document on how to reproduce the bug. Reproduce bug steps.pdf (805.4 KB)Please follow EXACTLY as it is. Thanks.


Thanks for sharing the steps to reproduce the issue.

We have followed the steps exactly and were able to notice the issue with Aspose.PDF for Java 19.10. Also, we noticed that document was converted/loaded successfully if Java Library has no Spaces in its Path.

We also repeated the same steps while using Aspose.PDF for Java 20.6 and in both cases (i.e. Spaces and No Spaces in Java Library Path) the same Exception was produced which we shared in our previous response.

We have updated the ticket details accordingly and will further investigate it. We would also like to share with you that issues are resolved in newer/updated versions of the API which is why we always recommend to use latest version. If an issue is logged for 19.10v, it will be resolved in the version higher than it. This is the reason we always test the scenario with the latest version of the API and if the issue does not occur we suggest upgrading the API else we log it for resolution.

Now that ticket details are updated, we will investigate it further and let you know as soon as we have some updates in this regard. Please spare us some time.

We are sorry for the inconvenience.

Thanks. please notify us once the fix comes out.


We will surely inform you as soon as we have additional updates regarding fix of the issue.

The issues you have found earlier (filed as PDFJAVA-39536) have been fixed in Aspose.PDF for Java 20.7.