Our customer bought Aspose.Words for JasperReports V21.9 - Developer OEM - 1 Developer and Unlimited Deployment Locations - Includes Maintenance and Support. The trial version runs fine. Now I want to embedded the license file. I copy the file into my project: C:\ISA\aspose\Aspose.Words.JasperReports.lic
Now I put following code into my method for .doc-reports:
AWDocExporter exporter = new AWDocExporter();
String strLicenseFile = new String("C:\\ISA\\aspose\\Aspose.Words.JasperReports.lic");
InputStream fstream = new FileInputStream(strLicenseFile);
//check file exists
File fl = new File(strLicenseFile);
if (fl.exists() && !fl.isDirectory()) {
String strExistFile = fl.getName();
}
com.aspose.words.jasperreports.License license = new com.aspose.words.jasperreports.License();
license.setLicense(fstream);
exporter.setParameter(AWExporterParameter.LICENSE, "Aspose.Words.JasperReports.lic");
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
exporter.exportReport();
He can’t finde the license file. The debugger said:
strLicenseFile:C:\\ISA\\aspose\\Aspose.Words.JasperReports.lic
fstream(path):C:\\ISA\\aspose\\Aspose.Words.JasperReports.lic
fl(path):C:\\ISA\\aspose\\Aspose.Words.JasperReports.lic
fl.exists is true
strExistFile:Aspose.Words.JasperReports.lic
I try the
license.setLicense(fstream);
also with the String as parameter:
license.setLicense(strLicenseFile);
But it’s the same problem. What it’s wrong with my code?
@sdenning As I can see in your code you set license after instantiating AWDocExporter
. Note, the license must be set before any Aspose.Words classes are instantiated. Please try moving setting license code into the application start before instantiating AWDocExporter
. Also make sure license.setLicense(fstream)
does not throw an exception.
If you would like to use the license as a parameter, it should be placed in the appropriate folder (for example your application’s folder or JasperReports\lib). Please see the Licensing section in our documentation.
Now I set the license first and than I use AWDocExporter exporter = new AWDocExporter();
but it’s the same problem. Cannot find license ‘Aspose.Words.JasperReports.lic’.
// Lokaler Test
String strLicenseLokal = new String(“C:\ISA\aspose\Aspose.Words.JasperReports.lic”);
InputStream fstreamLokal = new FileInputStream(strLicenseLokal);
File fLokal = new File(strLicenseLokal);
String strExistFileLokal = fLokal.getName();
if (fLokal.exists() && !fLokal.isDirectory()) {
// do something
String strOK = fLokal.getName();
}
com.aspose.words.jasperreports.License license = new com.aspose.words.jasperreports.License();
license.setLicense(fstreamLokal);
AWDocExporter exporter = new AWDocExporter();
exporter.setParameter(AWExporterParameter.LICENSE, “Aspose.Words.JasperReports.lic”);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
exporter.exportReport();
Same Error when I try to set the license with String:
license.setLicense(strLicenseLokal);
@sdenning Thank you for additional information. I suspect the problem is caused by the following line:
exporter.setParameter(AWExporterParameter.LICENSE, “Aspose.Words.JasperReports.lic”);
You do not need to use both methods to set the license. It is enough to use this code to set the license:
com.aspose.words.jasperreports.License license = new com.aspose.words.jasperreports.License();
license.setLicense(fstreamLokal);
So, please try to remove setting the license as a parameter. Please let me know if the problem still persist.
Now it works fine after I only set the license with license.setLicense(strLicenseLokal); and delete the AWExporterParameter.LICENSE, “Aspose.Words.JasperReports.lic”
There was a missunderstanding with the documentation Licensing|Aspose.Words for JasperReports
I put the first two steps in my code, because the documentation said “The first two are used with JasperReports”.
Thanks a lot!!!
@sdenning It is perfect that everything is working fine now. Thank you for pointing to the problem in our documentation. We will update it.