We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

GDI+ exception when converting from image to pdf

Hello,

I am using a ASP.net Core service in Kubernetes with Docker to convert images into pdf.
While converting I get following exception message:

“The type initializer for ‘Gdip’ threw an exception.”

I added already gdiplus to the dockerfile as described in another forum topic, but it didn’t resolve the problem.
Can you help, please?

Specifications:

OS: Docker container with Linux Debian (bullseye-slim)
ASP.net 6.0
GroupDocs.Conversion 22.12.0 (NuGet)

Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0.11-bullseye-slim
RUN apt-get update && apt-get install -y ffmpeg libgdiplus

RUN sed -i’.bak’ ‘s/$/ contrib/’ /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN fc-cache -f -v
WORKDIR /app
COPY . .
VOLUME /var/log

EXPOSE 80

#Run dotnet application
ENTRYPOINT [“dotnet”, “ConversionService.API.dll”]

@JuneTech

We are investigating this scenario. Your investigation ticket ID is CONVERSIONNET-5737. We’ll notify you if any further details are required.

@JuneTech

Please take a look at these release notes.

Section Public API and Backward Incompatible Changes:

You have to add runtimeconfig.json or runtimeconfig.template.json in next to the csproj file with the following content:

{
    "configProperties": {
        "System.Drawing.EnableUnixSupport": true,
    }
}

Let us know if it resolves the issue.

Thank you, this resolves the issue in .NET 6!
But I will switch to .NET 7 in the next days and the switch was removed by Microsoft for .net 7…

So this solution will not work for me.

You can lookup in the Microsoft documentation for the system.drawing error:

Note

  • This configuration switch was added to give cross-platform apps that depend heavily on this package time to migrate to more modern libraries. However, non-Windows bugs will not be fixed.
  • This switch is only available in .NET 6 and was removed in .NET 7.
1 Like

@JuneTech

We’ll further look into this scenario.

@JuneTech

We tested with .NET 7 and the runtimeconfig.template.json solves the issue so please try and let us know if there’s any issue.

Hi,

I tested it too and you are right, it still works in .NET 7.
So the note in the Microsoft documentation seems to be wrong.

Thank you!

1 Like

@JuneTech

You are welcome.