Free Support Forum - aspose.com

Validate that License is correct

Is there a way programmaticly to find out if the licence is correct or in evulation mode?


As this SO Answer states that you can check if the License is set in Java.
Hi Kurt,

Thanks for your inquiry.

There is no built-in method to check whether the license is already applied or not. However, if you want to be sure, you can try creating your own custom method to do this job. To do this you could create a blank document and export this to a stream. Then reload this and check the first paragraph in the body for the evaluation message.

///

/// Returns true if the Aspsoe.Words license is set.

///

private static bool IsLicenseSet()

{

// We will insert this text at the beggining of the document.

// If the license set this text will be in th efirt paragraph,

// if not an evaluation watermark will be in the first paragraph.

const string text = "This is text used to check if the license is set";

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write(text);

// Save and open the document. If Aspose.Words works in evaluation mode it will add a watermark.

using (MemoryStream docStream = new MemoryStream())

{

doc.Save(docStream, SaveFormat.Doc);

docStream.Position = 0;

doc = new Document(docStream);

}

// Check text of the first paragraph.

return (doc.FirstSection.Body.FirstParagraph.ToTxt().Trim() == text);

}


I hope, this helps.

Best regards,