Graph positioning moves during Excel to PDF conversion

Hi, I’m using Aspose Cells to convert an Excel spreadsheet file into a PDF file and in the PDF output, the graph positioning has moved to overlay the text below it. When I use Excel to print the spreadsheet to a PDF file, the positioning is maintained relative to the below text. Here is the input Excel filexlsm_input.zip (13.3 KB), the Aspose-generated PDF aspose_pdf_output.pdf (70.5 KB), and the Excel-generated PDF for comparison excel_pdf_output.pdf (450.4 KB). Are there any settings that could be used for the conversion so that the Aspose output matches the Excel output?

@sdonapati,

Thanks for the template file and output PDF documents.

I did test your scenario/case using your template XLSM file to convert to PDF via Aspose.Cells. I could not find any significant issue with the output PDF (generated by Aspose.Cells) regarding graphs rendering. There might be subtle difference regarding graph positioning which cannot be easily spotted. Could you please share a screenshot to highlight/differntiate the issue(s) comparing the PDF by MS Excel Vs the PDF generated by Aspose.Cells APIs. We will look into your issue soon.

Yes, here is a screenshot from the Aspose-generated PDF:aspose_screenshot.png (15.9 KB). The red graph overlaps the “Life to Date Activity” text below it.

Here is the Excel-generated PDF screenshot, where there is no overlap: excel_screenshot.png (37.6 KB)

@sdonapati,

Thanks for the screenshots.

Please notice, I am able to reproduce the issue as you mentioned (as per your screenshots) by converting your template Excel file to PDF. I found the Pie (red) graph overlaps the “Life to Date Activity” text below it. I have logged a ticket with an id “CELLSNET-52089” for your issue. We will look into it soon.

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

@sdonapati

Actually, the chart graph is not overlapped with the text below it. It is because that Row 34 is auto height, and the cached row height is 11.25 pt. When you open the source file in Excel, Excel recalculates the row height to 15.75 pt. You can using the following code to get the expected result.

Workbook wb = new Workbook("xlsm_input.xlsm");

//Height of Row 34 before auto fit.
Console.WriteLine("Before: " + wb.Worksheets[0].Cells.GetRowHeight(33));
wb.Worksheets[0].AutoFitRows(true);
//Height of Row 34 after auto fit.
Console.WriteLine("After: " + wb.Worksheets[0].Cells.GetRowHeight(33));

wb.Save("output.pdf");

@Peyton.Xu, I see, that makes sense. I modified the code to call AutoFitRows, and I’m now getting the correct output. Thank you for your help!

@sdonapati,

Good to know that your issue is sorted out by the suggested code segment. Feel free to write us back if you have further queries or issue, we will be happy to assist you soon.

A post was split to a new topic: JVMNotFoundException reported while using Aspose.Cells for Python via Java