Hi,
We are using aspose library (paid license) to convert doc to html (Aspose-words-19.4.jar). Sometimes, in the html converted file we are getting an aspose image being inserted at the top-left of html converted doc and a text message at the bottom of page - “Created with an evaluation copy of Aspose.Words. To discover the full versions of our APIs please visit: https://products.aspose.com/words/”.
Can you please share, how is this happening as we are using the paid version? Please share, if anything else is needed.
Thanks
Kunal Wadhwa
@kunal.wadhwa,
Please make sure that your code actually sets the License before creating instance of Document class. For more details, please refer to the following section of documentation.
How to apply License for Aspose.Words for Java
@awais.hafeez We are setting the license via explicit path method using setLicense method.
License license =new License();
license.setLicense(wordLicense);
//wordLicense is of type String containing the path at which Aspose.Words.lic file is kept on server.
Please note that this is being done per request. As already mentioned, the word to html conversion works fine and only on some occasion, we get the ASPOSE image added to top-left and the errors mentioned.
@kunal.wadhwa,
Please post your license file via private message. In order to send a private message with attachment, please click on my name and find “Message” button (see steps ). We will then investigate the issue with the license file on our end and provide you more information. Please do not share your license file publicly in this forum thread.
@kunal.wadhwa,
Thanks for sharing your license file via private message. But, the license file you shared is working perfectly fine on our end. I would like to mention a few points here:
- Make sure your call to SetLicense gets always executed. Debug your program and step through in the debugger to identify the problematic line of code.
- Make sure your code does not silently catch an exception thrown by Aspose.Words licensing code. For example, Aspose.Words will throw if it cannot find the license.
- Make sure the input documents do not already have the evaluation message. Aspose.Words does not delete existing evaluation messages.
- Make sure SetLicense is executed before you instantiate any Document object.
Hope, this helps.
@awais.hafeez Please find below the code snippet being used to convert from doc to html. In this, we are always setting the license for every request and then the conversion.
License license = new License();
license.setLicense(wordLicense);
Document doc = new Document(inputStream);
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
htmlSaveOptions.setSaveFormat(SaveFormat.HTML);
htmlSaveOptions.setExportImagesAsBase64(true);
doc.save(outputStream,htmlSaveOptions);
Is it a good idea to check via isLicensed() to check if license has been set or not?
In case it is not set, shall there be an attempt to set it again?
@kunal.wadhwa,
Your code should cause no problems and calling the License.SetLicense multiple times is not harmful either, but it simply wastes processor time. Secondly, isLicensed() method was obsolete and now a better way is to declare a global variable to determine whether a valid license has already been applied:
boolean isLicensed = false;
try {
License lic = new License();
lic.setLicense("E:\\temp\\aspose.total.java.lic");
isLicensed = true;
} catch (IllegalStateException ex) {
isLicensed = false;
}
if (isLicensed) {
Document doc = new Document("E:\\temp\\in.docx");
doc.save("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