I am using Select.HtmlToPdf.NetCore(18.3.0) to convert Html to pdf in Dotnetcore 2.1. It is perfectly working in local environment but when hosted with Docker it throws an error saying,
{"fileName":"System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory\n at Interop.Libdl.dlopen(String fileName, Int32 flag)\n at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()\n at System.Drawing.SafeNativeMethods.Gdip..cctor()\n --- End of inner exception stack trace ---\n at System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr& fontCollection)\n at SelectPdf.Lib.ᡜ..ctor()\n at SelectPdf.Lib...ctor()\n at SelectPdf.Lib...ctor(ᡏ A_0, A_1)\n
at SelectPdf.HtmlToPdf.ᜁ(String A_0, String A_1, String A_2, String A_3, Boolean A_4)\n at SelectPdf.HtmlToPdf.ConvertHtmlString(String htmlString)
I have tried by adding these set of lines in Dockerfile, but still having the same error.
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y libgdiplus
RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
WORKDIR /app
EXPOSE 80