Problem in setting license for Aspose PDF

Hi,
We are getting problems in setting the license for Aspose PDF for Java. We have upgraded Aspose PDF for java from version 17.4 to 17.8. The Aspose licence file we are using has expiry date 20180702 as shown below:
20180702

Following is the code snippets we are using for setting the license :
com.aspose.pdf.License pdfLicense = new com.aspose.pdf.License();
InputStream licenseStream = getClass().getResourceAsStream(“Aspose.Total.Java.lic”);
pdfLicense.setLicense(licenseStream);

This code executes successfully.

This code is executed only once at the time of startup of the application. However, in each request the output PDF generated using Aspose PDF contains following text at the top:
“Evaluation Only. Created with Aspose.Pdf. Copyright 2002-2017 Aspose Pty Ltd.”
Attached output file for your reference.

I am unable to figure it out as the same code was working fine with AsposePDF version 17.4

Can you please let me now what is causing the problem?
Is there something which got changed in between version 17.4 to 17.8?

Thanks,
Neeraj

aspose-pdf-output.pdf (31.2 KB)

@neergupta

Thanks for contacting support.

Would you please confirm if you are setting license in a separate thread and using API method in another thread (i.e multi-threaded environment)? This would help us in investigating the scenario and respond you accordingly.

Thanks for your response. Yes I am setting licence in one thread whereas executing API method in another thread.
However, this was what we were doing with earlier version and it was working fine. Moreover for all other aspose libraries - word, cells, slides and diagram - we are following the same approach and it’s working fine since last many years.

Thanks,
Neeraj

@neergupta

Thanks for sharing the requested details.

We have tested the scenario in a multi-threaded environment by using following code snippet and Aspose.Pdf for Java 17.8, and have observed that API was not using license while generating resultant PDF.

CompletableFuture<Void> appender = CompletableFuture.runAsync(new Runnable() {

@Override
public void run() {
try {
	File signatureFile = new File(dataDir + "Converted file.pdf");
	File contentFile = new File(dataDir + "aspose_source.pdf");
					
	// output file
	File outputFile2 = java.nio.file.Paths.get(dataDir, "joined.pdf").toFile();

	outputFile2.delete();

	try (InputStream is1 = new FileInputStream(signatureFile);
		InputStream is2 = new FileInputStream(contentFile);
		OutputStream os = new FileOutputStream(outputFile2)) {
		Document sig = new Document(is1);
		Document doc = new Document(is2);

		doc.getPages().add(sig.getPages());
		doc.save(os);
	}
      } catch (FileNotFoundException e) {
	e.printStackTrace();
} catch (Exception e) {
	e.printStackTrace();
}
}
			
});
		
try {
	appender.get(10, TimeUnit.MINUTES);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
	e.printStackTrace();
} 

Whereas, in the older versions of the API, same approach was generating valid PDF files, which we have tested as well. Hence, we have logged a regression issue as PDFJAVA-37084 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its correction.

However, for now, as a workaround, you may set license for the API in the same thread, where you are performing the document manipulations. As soon as we have some definite updates regarding resolution of the logged issue, we will inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thanks. We can not set license on each thread execution in production environment as it will be involve I/O and performance overhead during each execution. Although we keep working with this in our dev environments.
So kindly provide a fix ASAP on latest version.

Thanks,
Neeraj

@neergupta

Thanks for writing back.

Now that we have logged an issue in our issue tracking system, the product team will surely plan to provide a fix as per their development schedule. However, we have recorded your concerns and intimated the relevant team about them. As soon as we have some feedback from relevant team, regarding resolution progress, we will let you know. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi,
Can you please let me know if there is any update on this issue?

Thanks,
Neeraj

@neergupta

Thanks for your patience.

We are pleased to inform you that earlier logged issue has been resolved in latest version of the API. Please download Aspose.Pdf for Java 17.12 and try your scenario with latest version. In case you still experience any issue, please feel free to let us know.

Hi,
This is very much unfortunate that the given defect which was fixed in 17.12, has been re-introduced in the recent set of versions. I’ve tested the same with Aspose PDF versions 19.5 through 19.8.

Since it is a BREAK, can you please provide a hot fix ASAP as this is hampering our customers severely.

Thanks,
Neeraj

@neergupta

Would you please confirm if issue is still reproducible using the files and code snippet which was shared in this forum thread so that we can look further into this matter.

YES. It is still reproducible using the code snippet mentioned earlier.

Thanks,
Neeraj

@neergupta

We have re-opened the earlier closed ticket will investigate it again. We will surely let you know as soon as we have some additional updates in this regard. Please spare us little time.

We are sorry for the inconvenience.

@neergupta

It is to update this forum thread that the issue was already resolved in 17.9 version of the API and has been stable in 19.10v as well. You were facing the issue because the license being used was expired. The issue would not occur with a valid license.