Problem converting excel Workbook to PDF on linux cloud foundry

Hi,

I’m working on a dotnet core 3.1 application, and it involves creating xlsx, csv and pdf docs.
xlsx and csv works absolutely fine, but i get an exception when i try to save it as pdf. I’m using Cloud foundry, and environment is linux. However it works absolutely fine on my developement environment windows 10. I get the following exception :

2021-11-02T11:45:31.263+05:30 [APP/PROC/WEB/0] [OUT] [40m[32minfo[39m[22m[49m: GemboxExcel.Controllers.ExcelController[0]2021-11-02T11:45:31.263+05:30 [APP/PROC/WEB/0] [OUT] Generating pdf file …2021-11-02T11:45:31.275+05:30 [APP/PROC/WEB/0] [OUT] [41m[30mfail[39m[22m[49m: GemboxExcel.Controllers.ExcelController[0]2021-11-02T11:45:31.275+05:30 [APP/PROC/WEB/0] [OUT] The type initializer for ‘Gdip’ threw an exception.2021-11-02T11:45:31.280+05:30 [APP/PROC/WEB/0] [OUT] [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[13]

Can you please help me with this?

Hi Gurdeep,

Can you send us your Excel file so that we can investigate it?
It seems there is an issue with exporting a specific picture or perhaps a drawing element.

Regards,
Mario

Sure Mario. PFA the excel. Also, i have just imply created the table, there no images.

Hi Gurdeep,

I can’t investigate the screenshot…

Anyway, if there is no image then please send us a small Visual Studio project (together with your Excel file) that reproduces this issue.

Regards,
Mario

Hi Mario,

I have uploaded the code on github at URL https://github.com/gd8991/GemboxExcel
Kindly check. Thanks

Hi Gurdeep,

Your project is missing the System.Drawing.Common package.
Also, your Dockerfile is missing the libgdiplus package installation which is required by System.Drawing.Common.
Just as an FYI, note that we do plan to remove this dependency soon.

Also, your project is targeting aspnet:3.1-buster-slim which doesn’t have any fonts installed. Because of that, your Dockerfile will need to install some font package in order to generate a PDF file.

Does Cloud foundry already have some font files installed?
If yes, then you won’t have to install some font package.

Anyway, please take a look at our Docker example.

Let me know if you need anything else.

Regards,
Mario