Excel to PDF conversion - rendering PDF got stuck in multi-threaded environment in Java

Hi,

We are using the Aspose.Cell (version 8.1.1.2) Java API to generate a PDF from Excel sheet. However, we realized that save method got stuck and thread not getting released after one / two pdfs are generated.

For example, we are placing 50 messages in Weblogic JMS Queue and the listener will start to consume one by one. We are generating the pdf using Aspose Java API in the listener implementation. First few trades (like 5 trades) were processed successfully and the pdf was generated as well, and for subsequent message the request invoke save method but the control does not returns back which causes the thread stuck issue. Please help to advise us urgently.

public static synchronized Object savePDF(Workbook excelWb, int option) throws Exception {
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
excelWb.save(byteout, FileFormatType.PDF);
Object data = null;
if(option == SAVE_PDF_OPTION_BYTEARRAY){
byte[] output = byteout.toByteArray();
byteout.flush();
byteout.close();
data = output;
}else if(option == SAVE_PDF_OPTION_OUTPUTSTREAM){
data = byteout;
}
return data;
}

Regards,
Anbuselvam M

Hi,

Thanks for your posting and using Aspose.Cells.

Please download and try the latest version: Aspose.Cells for Java v8.9.2.6 and see if makes any difference and resolves your issue.

If your issue still occurs, then please check if this issue occurs with any excel file or with some particular excel files.

Please also provide us console application eclipse project that we could run at our end and investigate this issue. It will also be helpful, if you could provide us runnable jar files which we could execute directly. We will look into your issues and help you asap.

Please note, Aspose.Cells can be used in Multi-Threaded environment safely, but you cannot use the same Workbook object in multiple threads. You must have a separate Workbook object for each thread.

Here are few more things you can consider in diagnosing the issue.

We are not sure what’s the problem that caused the stuck issue, to trace the issue, we think you can:

1. Monitor the memory cost when processing those trades, if the memory cost increases and reaches the maximum limit, most time will be used for GC, so the process seems stuck.

2. Please check whether there is one special file for which the process always become stuck.

3. Please do the same process in one console application to see whether the same issue can be reproduced.