Aspose Cells .NET Core 2.1 saving workbook as PDF fails on Linux box



I have a .NET CORE 2.1 app with Aspose cells 18.6.0. It works great on windows machine but fails with following error when saving a workbook as PDF:

Aspose.Cells.CellsException: The type initializer for ‘Gdip’ threw an exception.
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)

This is line its failing on: workbook.Save(localPDFPath, SaveFormat.Pdf);

Details of linux box and .NET Core versions
.NET Core SDK (reflecting any global.json):
Version: 2.1.301
Commit: 59524873d6

Runtime Environment:
OS Name: debian
OS Version: 8
OS Platform: Linux
RID: debian.8-x64
Base Path: /usr/share/dotnet/sdk/2.1.301/

Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684

.NET Core SDKs installed:
2.1.301 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Please let me know if you need more details.



Thanks for using Aspose APIs.

Please do the following steps to resolve your issue.

  1. Install .NetCore SDK
  2. Install libgdiplus
  3. Copy the font files you need and call FontConfigs.SetFontFolder, please see this article i.e. Configuring Fonts for Rendering Spreadsheets

The installation command to install libgdiplus is as follows

sudo apt-get install libgdiplus
ln -s gdiplus.dll


Following above steps resolved the issue, thank you! Saving as PDF takes about 10 seconds on linux box vs few 100 milliseconds on the windows box. Is there any optimization need to be implemented for linux version?



Thanks for your feedback and using Aspose.Cells API.

We are glad to know that the solution suggested by us was helpful. In case you find any other issue or face some other problem, please feel free to post on our forums, we will be glad to help you further.

Difference in time might be an issue with relevant fonts on your Linux platform, either not installed or specified correctly with its path, please make sure that you have installed all the Microsoft true type fonts (used in the Excel file) on your system and then properly specify the fonts directory path in FontConfigs.SetFontFolder method, see the sample line of code that you should use it at the start of your program before creating Workbook and rendering to PDF.

Sample code:
FontConfigs.SetFontFolder("/usr/Temp/Fonts" , true);

Please see the document with example code for your reference:


Thank you for prompt response!

Setting FontConfigs.SetFontFolder doesnt seem to help, also PDFs created before and after using FontConfigs.SetFontFolder script has Calibri font in it. Any other thing I can look into?

Also I am getting below warning only for first PDF file generation, not sure if that can shed some light of slowness.
** (process:20744): WARNING **: NOT IMPLEMENTED: GdipWidenPath

** (process:20744): WARNING **: Requested 0 bytes. Maximum size for region is 262144 bytes.



Thank you for providing more details.

You may please try setting the image type as well because we use EMF as default image type which may be causing the above mentioned warnings.

Workbook workbook = new Workbook(filePath);PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;//This line is optional
opts.ImageType = System.Drawing.Imaging.ImageFormat.Png;
workbook.Save(filePath + ".out.pdf", opts);

If still your issue is not resolved, we have to log this issue in our database for which we need the template Excel file and the output PDF files for both Windows and Linux. It will help to analyze the problem.


Seems like opts.ImageType attribute is not available in .NET CORE version. Here is the requested sample and template files. You can also see some pie charts are missing in the linux (264.7 KB)



It seems that you have sent us different Excel file as it contains 4 charts wherever the alternate PDF files contains more than 12 charts. Please verify that appropriate set of files are shared for our analysis.


Its the same excel file, 2 tabs in excel will be converted into two pages in pdf per category. In the example PDF files I sent there are 6 categories thats why 12 pages, 2 page per category. Hope that make sense.



We were able to understand 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

CELLSNET-46223 - Performance degradation for XLSM to PDF conversion in Linux box with .NET Core 2.1


Sounds good, thank you!



You are welcome.