Free Support Forum -

Better Way to Check if Aspose.Words License is Already Set Than Creating a Document Every Time? [JAVA]

We currently are licensed to use Aspose.Pdf and there is a nice built-in method to check if we have already set the license: com.aspose.pdf.Document.isLicensed() so we don’t have to set the license every time we want to use an Aspose.Pdf.

However, in Aspose.Words, there is no similar functionality for the document class (com.aspose.words.Document) or the license class (com.aspose.words.License). After some Google searching it seemed the only way to verify the license was set was to create a document and insert some text, and return the text from the document. We check we just get the set text back and do not get this text back as well which is added in the word document if there is an evaluation copy being used: “Evaluation Only. Created with Aspose.Words. Copyright 2003-2019 Aspose Pty Ltd.”.

Is there a better way to do license checking that is fast and efficient rather than creating a temp document every time? Or could functionality be added?

Thank you!


We are checking this scenario and will get back to you soon.


You can declare a global variable to determine whether a valid license has already been applied:

boolean isLicensed = false;
try {
    License lic = new License();
    isLicensed = true;
} catch (IllegalStateException ex) {
    isLicensed = false;

if (isLicensed) {
    Document doc = new Document("E:\\temp\\in.docx");"E:\\Temp\\awjava-19.10.pdf");
} else {
    System.out.println("License not applied");

The License.setLicense() method will throw IllegalStateException for an invalid/wrong/expired license etc. Hope, this helps in achieving what you are looking for.