Excel export pdf in Docker linux container

Hi All,
I’ve tested the pdf export both on windows pc (running in iis express) and docker linux based image. I’ve modify the docker file to install the needed libraries:

# install System.Drawing native dependencies as Found in gembox guide https://www.gemboxsoftware.com/spreadsheet/examples/create-excel-pdf-on-docker-net-core/5902
# Update package sources to include supplemental packages (contrib archive area).
RUN sed -i 's/main/main contrib/g' /etc/apt/sources.list

# Downloads the package lists from the repositories.
RUN apt-get update

# Install System.Drawing.Common dependency.
RUN apt-get install  -y --allow-unauthenticated libc6-dev libgdiplus libx11-dev && rm -rf /var/lib/apt/lists/*

But the pdf in docker is a little bit flattened:

The pdf export in windows is well sized. Any ideas?

Thanks,
Regards

Dario

Hi Dario,

I’m afraid that without reproducing this and investigating the resulting files I cannot say anything for sure.

Nevertheless, I believe that the problem is probably due to different fonts being used on Windows and Linux systems.
Try taking all the fonts that your Excel file specifies from the Windows fonts, place them into your application’s folder, and use them as Private Fonts.

I hope this helps.

If the problem remains, please send us a small Visual Studio project (together with your Excel file) so that we can investigate it.

Regards,
Mario

Hi Mario,
I’ve tested the export also with excel that contains just an image.
The source code is very simple:

[AllowAnonymous]
[HttpGet]
[Route("[action]")]
public async Task TestExcelGembox()
{
string basePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), “Logs”);

        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
        
        // Save as pdf
        workbook.Save(Path.Combine(basePath, $"PWR-{DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss")}.pdf"), GemBox.Spreadsheet.SaveOptions.PdfDefault);

        return Ok();
    }

How can I share the excel? Consider that is very simple, it contains just the image logo seen above.
My docker file is:

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

Update package sources to include supplemental packages (contrib archive area).

RUN sed -i ‘s/main/main contrib/g’ /etc/apt/sources.list

Downloads the package lists from the repositories.

RUN apt-get update

Install System.Drawing.Common dependency.

RUN apt-get install -y --allow-unauthenticated libc6-dev libgdiplus libx11-dev && rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY [“Production.WebApi/Production.WebApi.csproj”, “Production.WebApi/”]

RUN dotnet restore “Production.WebApi/Production.WebApi.csproj”
COPY . .
WORKDIR “/src/Production.WebApi”
RUN dotnet build “Production.WebApi.csproj” -c Release -o /app/build

FROM build AS publish
RUN dotnet publish “Production.WebApi.csproj” -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [“dotnet”, “Production.WebApi.dll”]

In the meantime I’ll try to work with the fonts.

Thanks,
Regards

Dario

Hi Dario,

You can send us your Excel file via email or submit it as an attachment to a support ticket.
Please refer to our Contact page.

Regards,
Mario

Hi Mario,
I’ve sent the file in 25308

Thanks,
Regards

Dario

Hi Dario,

Your Excel file uses Calibri as a default font.
If you install this font on your Linux image or add it to your application as a private font, you’ll notice that the rows are rendered with the same height.

However, there is a small difference between the column widths, that is because GemBox.Spreadsheet currently uses System.Drawing.Common for this calculation.
Nevertheless, note that we are currently working on replacing this dependency, after that is done I believe there shouldn’t be any differences in calculations when the same font files are provided.

I hope this helps.

Regards,
Mario