Chart PDF not getting generated after the execution of chart.toPdf(fileName) method

Hi,

I am using Aspose.Cells v8.6.1.6
I am converting Chart 1 in the attached excel file to PDF using chart.toPdf(fileName) api. The PDF is not generated after the execution of line 5. Its size remains 0 KB. The pdf gets generated only after the entire execution of the program is completed.

For reference the sample code:
private static void chartToPDF() throws Exception { //line 1
Workbook workbook = new Workbook(“test.xlsx”); //line 2
WorksheetCollection ws = workbook.getWorksheets(); //line 3
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 1”); //line 4
chart.toPdf(“D:\test.pdf”); //line 5
System.out.println(“PDF is saved at location : D:\test.pdf”); //line 6
}

I even used workbook.dispose() method after line 5 to release resources but it didn’t work.
Can you please analyse this issue and see if there is any workaround for this problem?

Thanks,
Neha Gautam

Hi,


Thanks for providing us some details and sample code.

Well, I have tested your scenario/ case using your template file and sample code with v8.6.1.6, it works fine and it generates the output PDF file (containing the chart) fine. I have attached the output PDF file using your sample code with v8.6.1.6 for your reference.

Please make sure that you are using our latest version/fix: Aspose.Cells for Java v8.6.1.6.

Thank you.

Hi,


The issue is that the pdf gets generated after the whole program has executed and the jvm gets closed. But the pdf is not generated just after the execution of chart.toPdf() method. In the following sample code, if you will apply a breakpoint on line 6 and check if the pdf is generated at this point, you will see that the pdf is of 0KB size and it wont open.

Sample code:
private static void chartToPDF() throws Exception { //line 1
Workbook workbook = new Workbook(“test.xlsx”); //line 2
WorksheetCollection ws = workbook.getWorksheets(); //line 3
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 1”); //line 4
chart.toPdf(“D:\test.pdf”); //line 5
System.out.println(“PDF is saved at location : D:\test.pdf”); //line 6
}

Can you please analyse this issue.

Thanks,
Neha Gautam

Hi,


Thanks for providing further details.

Well, I still could not find any issue. But we think it is quite possible for such kind of issue when creating PDF from the chart. I think as I can get the resultant file immediately without any problem due to the fact that my simple/small test application finished immediately after the generation. But if one creates the PDF in a long program with long time running/ processing, then one may find such an issue. We need to check it thoroughly if we flush and close the file fine immediately in the code behind.

I have logged an investigation ticket with an id “CELLSJAVA-41578” for your issue. We will evaluate and fix the issue (if found) soon.

Once we have any update on it, we will let you know here.

Thank you.

There seems to be a problem with the resource cleaning in the method chart.toPdf(…).

For better understanding kindly execute the following code:

private static void chartToPDF() throws Exception { //line 1
Workbook workbook = new Workbook(“test.xlsx”); //line 2
WorksheetCollection ws = workbook.getWorksheets(); //line 3
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 1”); //line 4
chart.toPdf(“D:\test.pdf”); //line 5
System.out.println(“PDF file deleted:” + new File(“D:\test.pdf”).delete());
}

You will see that you will not be able to delete the PDF file which has been generated. It will print the following:
PDF file deleted: false
Whereas if we do the same thing with chart.toImage(…) it works fine.

Thanks,
Neha



Hi,


Thanks for providing us further details.

You are right. There looks to me an issue with resources’ releasing in Chart.toPdf() method as you pointed out. After adding your suggested line to the code segment would print:
PDF file deleted: false

I have logged your comments to attached with your existing ticket “CELLSJAVA-41578” into our database. Our concerned developer will look into the details and try to figure your issue out soon.

Once we have any update on it, we will let you know here immediately.

Thank you.

Hi,

Thanks for using Aspose.Cells.

This is to inform you that we have fixed your issue CELLSJAVA-41578 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-41578) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.