Problem with Aspose.Pdf.lic file when deployed on AWS lambda

I have a 30-day evaluation license for Java I got from you recently and I will soon buy it if I solve the next problem:

I have read these instructions:
https://docs.aspose.com/display/pdfjava/Aspose.Pdf+Java+%28Maven%29+for+Eclipse#Aspose.PdfJava(Maven)forEclipse-HowtoapplyAsposeLicense?

So I renamed the file from ‘Aspose.Pdf.lic’ to ‘Aspose.Pdf.Java.lic’ and I use this code:

License licensePdf = new License();
licensePdf.setLicense(“Aspose.Pdf.Java.lic”);

I have the renamed file ‘Apsoe.Pdf.Java.lic’ file in the folder ‘C:\Users\Vladimir.VASOVIC.m2\repository\com\aspose\aspose-pdf\18.12’

I also have it in the src/main/resources folder.

And this is my pom.xml file:

<dependency>
    	<groupId>com.aspose</groupId>
    	<artifactId>aspose-pdf</artifactId>
    	<version>18.12</version>
</dependency>
<repository>
	<id>snowtide-releases</id>
	      <url>http://maven.snowtide.com/releases</url>
	      <releases>
	          <enabled>true</enabled>
	      </releases>
</repository>
<repository>
	<id>AsposeJavaAPI</id>
	<name>Aspose Java API</name>
	<url>https://repository.aspose.com/repo/</url>
</repository>

It works perfectly locally in Eclipse (when I run unit/integration tests), but when I deploy it on AWS lamba, I get this message:

Expeption message - class com.aspose.pdf.exceptions.PdfException: At most 4 elements (for any collection) can be viewed in evaluation mode.

Pleeeaseeee help!!!
This is so frustrating!!!

@vvasovic

Thank you for contacting support.

Would you please elaborate a little more if Aspose.PDF for Java API is working fine in AWS Lambda environment or not, except this Evaluation problem. You may try to execute a single line of code as a test.

Document document = new Document();

It can rule out or highlight any problem about downloading and working of Aspose.PDF for Java API in your project. Secondly, please try to specify full path to the license file. You may also try to verify that the license file is accessible to the API, by reading the file into FileInputStream or ByteArrayInputStream. You may try to Validate the License and share your feedback so that we may investigate further to help you out.

When I use if (com.aspose.pdf.Document.isLicensed())… else… I got this message:

Exception: License is NOT Set! - java.lang.Exception: Cannot find license ‘Aspose.Pdf.Java.lic’.

BTW, I export it to the jar file from Eclipse and in the jar file the file ‘Aspose.Pdf.Java.lic’ is stored in the folder ‘resources’

I have also tried to put ‘licensePdf.setLicense("/resources/Aspose.Pdf.Java.lic");’, but it still doesn’t work. The message is:

Exception: License is NOT Set! - java.lang.Exception: Cannot find license ‘/resources/Aspose.Pdf.Java.lic’.

I was able to solve this issue with this code:

licensePdf.setLicense(/var/task/resources/Aspose.Pdf.Java.lic);

I determined the resourse folder path with this method:

Path url = Paths.get(ClassifyFormFunction.class.getResource("/").toURI());
String path = url.toString()

Thanks

@vvasovic

Thank you for your kind feedback.

We are glad to know that your issue has been resolved. Please keep using our API and in event of any further query, feel free to ask.