Support of Linux Docker Containers for Aspose.Slides 24.9 with .NET 8

Hi,

I have a few questions.

Can you provide an example of the correct docker file for dotnet8 for linux container?
because docker file below always fails with error:

  • System.Drawing.Common is not supported on this platform.
    for lines
    -System.Drawing.FontFamily.get_GenericSerif()

  • -at Aspose.Slides.Paragraph.GetLinesCount()

As you can see, I`ve tried to install dependencies in different ways

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

# Install dependencies for Aspose Slides
# - 'libgdiplus' for System.Drawing support
# - 'fontconfig' to manage fonts on macOS/Linux
#RUN apt-get update && \
    #apt-get install -y libgdiplus fontconfig && \
    #rm -rf /var/lib/apt/lists/*
    # RUN yum install -y libgdiplus glibc-devel  libfontconfig1 libfreetype6 libexpat1 libpng16-16

# Install dependencies for Aspose Slides
# - 'libgdiplus' for System.Drawing support
# - 'fontconfig' to manage fonts on macOS/Linux
# Update dependencies for System.Drawing


RUN apt-get update && apt-get install -y \
 libgdiplus \   
 libfontconfig1 \
 libfreetype6 \
 libexpat1 \
 libpng16-16

# RUN apt-get update
# RUN apt-get install -y libgdiplus libexpat1 libpng16-16
# RUN cd /usr/lib \
#     && ln -s libgdiplus.so gdiplus.dll
# RUN apt-get install -y libc6
# RUN apt-get install -y libc6-dev libx11-dev
# RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
# RUN rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

ARG BUILD_CONFIGURATION=Release
ARG DOWNLOAD_ASPOSE_LICENSE=false

WORKDIR /src

COPY ["Directory.Build.props", "."]
COPY ["Services/API.csproj", ".API/"]
RUN dotnet restore "./Services/API/API.csproj"

COPY . .
WORKDIR "/src/Services/API"
RUN dotnet build "./API.csproj" -c $BUILD_CONFIGURATION -o /app/build  /p:NoWarn=CS1591

FROM build AS publish
RUN dotnet publish "./API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final

WORKDIR /app
COPY --from=publish /app/publish .


ENTRYPOINT ["dotnet", "API.dll"]

@GeorgiyS

To address your questions regarding the support of .NET 8 with Aspose.Slides and the Docker configuration, here are the details:

  1. Support for .NET 8: The Aspose.Slides for .NET 6 package is compatible with .NET 7 and future .NET releases, including .NET 8. Therefore, you can use the Aspose.Slides.NET6.CrossPlatform package for your .NET 8 applications. The standard Aspose.Slides.NET package, however, relies on System.Drawing.Common, which is not supported in Linux environments.

  2. Dockerfile Example: Below is a sample Dockerfile that should work for your .NET 8 application using Aspose.Slides without encountering the System.Drawing.Common issue. This configuration includes the necessary dependencies for running Aspose.Slides in a Linux container:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

# Install dependencies for Aspose Slides
RUN apt-get update && apt-get install -y \
    libgdiplus \
    libfontconfig1 \
    libfreetype6 \
    libexpat1 \
    libpng16-16 && \
    rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Directory.Build.props", "."]
COPY ["Services/API.csproj", "Services/"]
RUN dotnet restore "Services/API.csproj"

COPY . .
WORKDIR "/src/Services"
RUN dotnet build "API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "API.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "API.dll"]

Key Points:

  • Ensure you install libgdiplus and libfontconfig1 as they are essential for handling graphics in a Linux environment.
  • The System.Drawing.Common library is not supported on Linux, so using the cross-platform version of Aspose.Slides is crucial.

If you continue to face issues, make sure that all necessary font packages are installed, as missing fonts can also lead to errors during rendering.

Feel free to reach out if you have any more questions or need further assistance!

Sources:
[1]: PPTX to PDF: System.Drawing.Common Is Not Supported on This Platform