Different excel charts of same size have different size in the PDF output

Hello,


I am using Aspose.Cells 17.5.5 to generate PDFs of excel charts.

The size of the chart in output is different from the actual size of the chart. Moreover, the size is inconsistent, i.e., chart size in output is different for different charts even when the charts are of same size in excel.

I have attached two examples for your reference. The examples contain a screenshot comparing PDF outputs of 2 charts which are of almost same size in the excel, but their size in the PDF output is extremely different.

Following code has been used to generate the PDF:
Workbook workbook = new Workbook(“Example1_Chart1.xlsm”);
WorksheetCollection ws = workbook.getWorksheets();
String worksheetName = “Sheet1”;
Chart chart = ws.get(worksheetName).getCharts().get(“Chart1”);
chart.toPdf(“Example1_Chart1.pdf”);

Can you please look into this.

Thanks,
Neha

Hi,


Thanks for the template files, sample code and screenshots.

I have tested your scenario/case using your sample code with your template files (with our latest version/fix: Aspose.Cells for Java v17.5.6 (attached) - please try it), it works fine and I do not see inconsistent charts’ sizes for Example1 charts and Example2 charts. For reference, I have attached the output PDFs and a screenshot (to view the Example1 charts when opening the files into Adobe acrobat in 150% zoom). Similar would the case when you open the Example2 charts in Adobe acrobat in 150% zoom. You would notice the sizes are almost ok and not inconsistent as per your screenshots.

Thank you.

Hello,

Since the given issue was clearly reproducible in one our customers production environment, we have analysed it further to figure out the root cause.

After analysis we found that issue is environment specific as it is not reproducible on all machines. That could be the reason you were also not able to reproduce this in your setup.

To facilitate the troubleshooting we have created a VM with public IP where the issue is clearly reproducible.

Following are the steps to reproduce the issue:

  1. RDC to the following machine:
  • Machine IP: 52.163.124.173
  • User Name: testuser
  • Password: Aspose123456
  1. Go to folder C:/ForAspose which contains following:
  • Two excel documents - Chart1.xlsm and Chart2.xlsm where each contain chart of same size.
  • Java test client ChartSizingIssue - both class file and java file.
  • Aspose jar file
  • Aspose licence file “Aspose.Total.Java.lic”. This is the dummy file you have to replace it with valid license file or update its content during execution of the program.
  • run.bat file to run the program.
  1. Execute run.bat file which will generate output folder and create 2 chart files.

  2. Now compare output of both PDF files side by side by changing zoom factor to 100%.

I have also attached the comparison of both output PDF files for your reference.

This is very critical issue as layout of customer documents containing these charts is heavily affected.
So kindly look into this on priority provide the fix ASAP.

Thanks,
Neeraj
OutputComparison.PNG (50.4 KB)

@neergupta,

Thanks for providing us details and screenshot.

We have evaluated your issue a bit. We found Chart1.xlsm default font is “Arial Narrow”, it is missed on the user’s env.
e.g
Sample code:

FontConfigs.setFontExclusiveSources(new FontSourceBase[]{new FolderFontSource(FontExcDir, false)});
  
  Workbook workbook1 = new Workbook("D:\\Download\\ForAspose\\CHART2.xlsm");
  WorksheetCollection ws1 = workbook1.getWorksheets();
  Worksheet sheet11 = ws1.get("ReportCharts");
  Chart chart1 = sheet11.getCharts().get("GFTU_price vs EPS");
  chart1.toPdf(TMP_DIR + "chart2.pdf");

  
  Workbook workbook = new Workbook("D:\\Download\\ForAspose\\CHART1.xlsm");
  WorksheetCollection ws = workbook.getWorksheets();
  Worksheet sheet1 = ws.get("8 charts");
  Chart chart = sheet1.getCharts().get("GFTU_WIDTH TEST_CHART");
  chart.toPdf(TMP_DIR + "chart1.pdf");

Using the code and only putting Arial font (arial.ttf) to the FontExcDir, the issue can be reproduced on your end. Then add “Arial Narrow” font to the FontExcDir, the output will be ok.

Thank you.

Hi,

Thanks to figure out that installing fonts works well. However, I was wondering that no where in the charts we are using “Arial Narrow” fonts although it is being used else where, then why the behaviour is appearing in those charts PDF rendering?

As far as your license related concern, we have a valid Aspose license however, I did not use that license in the public VM as Aspose topics are public and anyone can view that.

Thanks,
Neeraj

@neergupta,

Good to know that your issue is sorted out by installing the required font (“Arial Narrow”). Well, for rendering of shapes, default font (used in the workbook) is needed. We may provide further details for your reference.

You did it well not to include license file on public VM. By the way, did we show any concern regarding it?

Thank you.