We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspect ratio is not maintained in PDF output of excel chart


I am using Aspose cells v8.5.2.4

On converting Chart 1 to PDF the aspect ratio is not preserved, initial chart size is 5X3 inches but 5.26X2.88 inches in PDF.

For reference, sample code & documents attached

Workbook workbook = new Workbook(“Excel.xlsx”);
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 1”);
ChartShape cshape = chart.getChartObject();
int sheetIndex = ws.add();
com.aspose.cells.Worksheet worksheet = ws.get(sheetIndex);
double chartWidthInInches = chart.getChartObject().getWidthInch();
double chartHeightInInches = chart.getChartObject().getHeightInch();
boolean defaultApproach = true;
if (chartWidthInInches > 18 || chartHeightInInches > 5) {
// The approach being followed here is to iterate as many columns as colwidth in pixels & set each column width equal = 1 pixel.
// Similarly for chart height, iterate through as many rows as row height & set each row height = 1 pixel.
// This is being done to fit in large charts that have height & width beyond maximum row/col dimensions & white spaces around
// the chart.

double chartWidthInPixels = chart.getChartObject().getWidth();
double chartHeightInPixels = chart.getChartObject().getHeight();
// Deliberately including one more column because Aspose considers the last column adjacent to chart which leads to white space
// on right of chart
for (int i = 0; i <= chartWidthInPixels; i++) {
worksheet.getCells().setColumnWidthPixel(i, 1);

// Deliberately including one more row because Aspose considers the last row adjacent to chart which leads to white space
// below the chart.
for (int i = 0; i <= chartHeightInPixels; i++) {
worksheet.getCells().setRowHeightPixel(i, 1);
defaultApproach = false;
} else {
worksheet.getCells().setColumnWidthInch(0, chartWidthInInches);
worksheet.getCells().setRowHeightInch(0, chartHeightInInches);

//Setting the name of the newly added worksheet
String transientSheetName = “TransientWorksheet”;
//Copy the Chart to Second Worksheet
worksheet.getShapes().addCopy(cshape, 0, 0, 0, 0);
//Get the new chart and set its height and width accordingly
com.aspose.cells.Chart chart1 = worksheet.getCharts().get(0);
//Make remaining worksheets invisible so that they are not part of the output pdf
for (int i = 0; i < ws.getCount(); i++) {
String sheetName = ws.get(i).getName();
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
//Setting Print area to first cell only as the chart is contained in the first cell (A1:A1)
if (defaultApproach) {
// Save the workbook
workbook.save(“d:\temp\Chart 1.pdf”, pdfSaveOptions);


Hi Jaspreet,

Thanks for your posting and using Aspose.Cells.

Your issue is not quite clear. Please provide us screenshot comparing the results of the excel and the pdf for our investigation. Please also let us know how you are measuring the aspect ratio of your excel file as well as your pdf file. We will look into your issue and help you asap.


For reference I have attached the screen shot.

In Excel the chart size is
Height 3"
Width 5"

In PDF output of chart, via Document properties I could see the Page Size 5.26 x 2.88 in



Thanks for your screenshot and using Aspose.Cells.

We were able to replicate this issue after executing your above code with the latest version: Aspose.Cells
for Java v8.6.0.3
and found aspect ratio does change.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41496 - Aspect ratio is not maintained in PDF output of excel chart


At IHS we also have Aspose.cells license and we have encountered this problem too.

Fixing it is important for us, because our users face it in everyday work.


Hi Tomek,

Please note, the ticket attached to this thread is currently in analysis phase therefore we cannot share an estimated time line for fix at the moment, however, as soon as we receive any updates regarding the aforementioned ticket, we will post here so you could subscribe to this thread for updates.

That said, we strongly suggest you to create a new thread with problem description and supporting documents so we could evaluate the problem separately and log separate ticket, if applicable.


Thanks for using Aspose.Cells.

When converting to pdf, there are scales in width and height. And you can check excel generated pdf, the chart width and height is also scaled. So this issue is not a bug and won’t be fixed.


I tried saving excel Chart 1 in workheet Aspect Ratio PDF to PDF via MS Excel, but I get the PDF with lots of white space around.
So how can I figure out the that if in MS Excel the chart dimensions are 3 x 5 inches, the PDF via MS Excel has same/different aspect ratio, because the MS excel PDF is not just the chart, but also lots of white space around, so I can’t compare that.



Thanks for your feedback and using Aspose.Cells.

We have logged your comment and files in our database against this issue for product team consideration. We will look into it and update you. Once there is some news for you, we will let you know asap.


We have evaluated your issue further. For comparison, we just change page layout orientation to landscape to make sure the whole chart in one page. Then we save the Excel file to PDF by Aspose.Cells and by MS Excel (manually). You’ll find the chart width in Excel is 5 inch = 5 2.54 cm = 5 96 pixels = 480 pixels(in 96 DPI). But in the PDF (opened by chrome), the chart width is 515 pixels. You can also measure chart height by the same way.

Thank you.


Please try our latest version/fix: Aspose.Cells for Java v8.6.2, you may download it here:

Please try using Chart.toPdf() method directly to generate chart report.

Thank you.


I am using chart.toPdf() method of Aspose.Cells v8.6.3.4 to test this issue. Unfortunately, this issue still exists. Aspect Ratio is not maintained in the PDF output.

Actual chart size 5 X 3 inches but in PDF, the size is 5.01 X 3.01 inches. I have attached the PDF generated using Aspose.Cells v8.6.3.4.

Can you please analyse this issue.



Thanks for your posting and using Aspose.Cells.

You are actually telling the page size 5.01x3.01 and not the chart image size. The chart image size is 5x3. Please take the screenshot of the image and copy it in MS-Paint and then measure the image size and you will find it is 5x3.


Thanks for using Aspose.Cells.

For your further clarification, as the chart border width is 1pt, the Aspose generated pdf size is bigger than excel.

In excel, the size( 5 * 3 inches) doesn’t include the border size of chart. So when we set the width of border of chart to big value, the size is still not changed.

Please check the two charts in ChartBorder.xlsx. The size of both charts is same, but actual size of chart is not same. So when generate them to pdf, we will get different size pdf.

In first chart, excel size is 5*3 inch. The boder width is 1 pt. So the pdf will be 5 3 inch + 1 1 pt