Because License.setLicense() accepts InputStream as parameter, I think you can read the license file’s content into memory and encode it to build a new ByteArrayInputStream from it for License.setLicense().
Code sample can be following:
File file = new File("…"); //license file byte[] buffer = new byte[(int)file.length()]; FileInputStream fis = new FileInputStream(file); fis.read(buffer); fis.close(); String xml = new String(buffer, charset1); buffer = xml.getBytes(charset2); ByteArrayInputStream bais = new ByteArrayInputStream(buffer); new License().setLicense(bais);
Well, it looks strange to us. Do you mean you got no exception when you set the license, but an evaluation sheet appears in the generated file? If no exception caused by License.setLicense() method, the license should be set successfully and there should be no more evaluation sheet. By the way, if you could try the attached version v2.4.7, you can use License.isLicenseSet() method to check whether the license has been set or not.
For this error, I am afraid you have not changed the encoding of license file correctly. To isolate the encoding problem, I think you can take the license file as a common xml file and parse it without using Aspose.Cells API. you may try the following code:
I set my file.encoding to Cp1140, so I converted the license-file to CCSID 1140. When I google for this kind of error, I find the xml-parser finds symbols before the <?xml> tag I also find solutions saying to change UTF-8 by utf-8 (lower case).
Will the signature still be valid when I change this in the license file ?
We have tried to set file.encoding=cp1140 and found the license can be set successfully by License.setLicense(InputStream), where the stream is a FileInputStream built from the license file. And we need no any extra code to process the encoding. Are you using the original license file or have modified the file mannually? And would you please test the sample code we provided in previous reply(http://www.aspose.com/community/forums/permalink/270963/270563/showthread.aspx#270563) to check whether the xml can be parsed successfully? The result of this test can help us to find what's the problem.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.