Aspose Cells .NET Core charts formatting issue on linux box

Hello,

I am using .NET Core 2.1 with Aspose Cells 19.1.0 to create pdf files using an xlsm template. When I run the application on a windows box, resulting PDF with charts looks good but same code running on a linux box, causes issues with charts.

Here is the code use to same xlsm as pdf:
workbook.Save(localPDFPath, SaveFormat.Pdf);

One issue we ran into so far is both Y-Axis and X-Axis labels getting cut off. Especially X-Axis is showing only one line of data.

I am attaching PDF output files generated on both windows and linux, and also the xlsm template file used to generate the pdf.
Files.zip (473.5 KB)

  1. In 'PC 37_Linux.pdf", on page 2 you can notice that Y-Axis label “% Change by SKU” being cut off on but same chart on “PC 37_Windows.pdf” looks fine.
  2. “In PC 37_Linux.pdf”, on page 2 you can notice that X-Axis labels are just one line but same chart on “PC 37_Windows.pdf” looks fine with two lines of X-axis and all lines are visible.
  3. Similar issue like #2 but for vertical x-axis labels on “PC 419_Linux.pdf” Page 12 notice the vertical x-axis labels are being cut off on linux but not on windows.

Hope its clear to illustrate the problem.

Note: This is a followup from Aspose Cells .NET Core 2.1 saving workbook as PDF fails on Linux box - #52 by rw3

@rw3,

We need to create these PC 37_Linux.pdf, PC 37_Windows.pdf, PC 419_Linux.pdf and PC 419_Windows.pdf here for our analysis whereas the template file XLSM cannot be used to create these PDF files. You are requested to provide us a complete solution (runnable) which can be used to create these PDF files here as it will help us to observe the problem and provide assistance accordingly.

OK, here is a sample solution, you should be able to run it both windows and linux, and compare the PDFs created with differences in each environment. Aspose Sample App.zip (87.3 KB)

Note: This application will create a pdf file named: plancall_1.pdf

@rw3,

Thanks for the sample solution. I am afraid that this project could not be compiled in my environment.

However I got an XLSX file in the solution named “PC 254.xlsx” which was converted to PDF using following sample code:

Workbook workbook = new Workbook(@"PC 254.xlsx");
PdfSaveOptions options = new PdfSaveOptions();
options.OnePagePerSheet = true;
workbook.Save(@"PC 254.pdf", options);

You may please use above mentioned sample code and “PC 254.xlsx” file to create a PDF and identify the issues there as I could not observe any issue in the generated PDF in my environment.

Note:In your first post you mentioned issues in “PC 37” and “PC 419” however the sample file provided with this solution is PC 254.

Thanks for trying it! Yeah, all my sample solution was doing is taking the xlsx file and saving as pdf.

I tried your PdfSaveOptions code option and I am still seeing the issue. Did you try to generate the file on both windows & linux for comparison? I am not having any issues with windows version, it just the linux version has the problem. Attaching the file generated on windows vs linux.

Regarding your note, we generate thousands of files thats why I sent a different PC 254 instead of PC 37 and PC 419. Issue can be seen in all the files.

Files.zip (240.3 KB)

@rw3,

We have understood the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNETCORE-21 - Y-Axis label being cut off

Note: With the given sample file only Y-Axis label cut off issue is observed in your output PDF files. Please provide some other sample file along with the output PDF files in Linux and Windows for other issues mentioned in the first post.

@rw3,

  1. Please try our latest fix/version: Aspose.Cells v19.1.1 (attached). The Y-Axis label “% Change by SKU” will be improved in it.

  2. For the X-Axis labels, we checked it on both windows and linux. In fact, the X-Axis labels are not totally shown on windows either. For example, the label “STOKERS 1.2 OZ CAN - LONG CUT WINTERGREEN (31029)”, on windows is drawn as “STOKERS 1.2 OZ CAN - LONG CUT WINTERGREEN”, whereas on linux, it is drawn as “STOKERS 1.2 OZ CAN - LONG CUT”. so we will keep on working to improve it on both windows and linux.

Once we have any new information, we will share it with you.
Aspose.Cells19.1.1 For .NetStandard20.Zip (3.9 MB)

Sounds good, thanks

@rw3

For your issue, we have fixed it on Windows, but on linux there is still a problem which is caused by System.Drawing.Common lib.
We write a simple test case:

//you may put any test bmp file here
System.Drawing.Image img1 = Image.FromFile(Constants.BasePath + "TestBitmap.bmp");
Graphics g2 = Graphics.FromImage(img1);
SizeF layoutArea = new SizeF(75, 47);
Font font = new Font("Calibri", 7);
string text = "STOKERS 1.2 OZ CAN - LONG CUT WINTERGREEN (31029)";
StringFormat sf = new StringFormat(); 
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
SizeF sizeF = g2.MeasureString(text, font, layoutArea, sf);

The result “sizeF”, on windows is 68.13(width), 46.74(Heigth), this is correct.
But on Ubuntu 16.04 the result is 58(width), 30(Heigth), we can see the Height is not correct.
We think the problem occurs when:

  1. The width of “layoutArea” is not very long, for example in this case it is only 47.
  2. The “text” is much longer than “layoutArea”, and it will cause several new lines.

As the problem is caused by System.Drawing.Common lib, we have reported it to Microsoft.
In next version/fix, the “cut off” problem will be improved, both on Windows and linux.
But as the problem (we said before) may be still there where some words cannot be shown fully.

Once the fix is available, we will let you know.

Ah I see, good to know, please let me know when the fix is available for linux.

@rw3,

Sure, we will keep you posted once an update is available.

@rw3,

As we think Microsoft may not fix it in short time, we have fix for the “Y-Axis being cut off” problem by giving the measure result a fix value. Please use Aspose.Cells 19.2.6 version to check it, the test result has been improved when saving “PC 254.xlsx” to PDF on Linux.

Please try our latest version/fix: Aspose.Cells v19.2.6 (attached).
(you may choose/download appropriate fix for your underlying .NET Framework version)
Aspose.Cells19.2.6 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.2.6 For .Net4.0.Zip (4.8 MB)
Aspose.Cells19.2.6 For .NetStandard20.Zip (3.9 MB)

Let us know your feedback.

Hello,

Thanks for the update, I am using NuGet to manage the references to the project so I tried to remove the existing NuGet aspose reference and replaced it with your recent aspose.cells dll file. But I get below error when trying to run the project, is there any other dlls need to be added?

System.IO.FileNotFoundException: Could not load file or assembly ‘System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’.
The system cannot find the file specified.File name: 'System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’at​.()at​.()at …ctor(Cells )
at Aspose.Cells.Cells.()at Aspose.Cells.Worksheet…ctor(WorksheetCollection )at Aspose.Cells.WorksheetCollection.Add()at . ( )at .( , Boolean )
at .()at .()at.(Workbook , LoadOptions , Boolean )at .(String , Stream , LoadOptions )at Aspose.Cells.Workbook.(String , LoadOptions )

@rw3,

These dependencies are required now with v19.2.x, however these were not required in v19.1. You may please add System.Drawing.Common from the NuGet package manager to resolve this issue.
In some cases you may also require System.Text.Encoding.

You can get this information for .NET Standard by clicking on “Dependencies” node after the “Release Notes” at the following link:

Hello,

This version of the library definitely improved number of text being displayed but we still see the cut off issue. Is there more improvements being done?

Also we are seeing pie chart data labels overlapping with each other. This wasnt happening in non-core version of the library.

Attaching a sample image of the pie chart issue: pie chart issues.png (33.9 KB)

In the image, left hand side pie chart is created from .net core vesion of the library, right hand side one is from regular .net version library.

@rw3,

We are aware that some words can not be shown completely. It will be resolved once Microsoft fixes the issue. CELLSNETCORE-21 issue is not closed therefore. We will let you know as soon as issue will be resolved.For overlapping issue, please share the file or name of it if shared already with the code snippet for our analysis.

Ah I see, thanks. Yes pie chart issue can be seen in “PC 419_Linux.pdf” file original Files.Zip attached at the top, please let me know if you need anything else.

@rw3,

Thank you. I have recorded your feedback with the issue. We will write back here once any feedback is ready to share.

@rw3,

We have reproduced this issue using your sample file named “TMP - Plan Call Page.xlsm”, which you provided last year. The pie chart problem appears both on Windows and linux when using “TMP - Plan Call Page.xlsm”. We will try to fix the issue both on Windows and linux.

Once we have any new information or fix available, we will let you know.

Sounds good, thanks!