作者:人帅刀快爱美女_915 | 来源:互联网 | 2022-12-06 13:02
如何解决《使用Select.HtmlToPdf.NetCore时,DockerizedDotnetCore2.1引发Gdip异常》经验,为你挑选了1个好方法。
我正在使用Select.HtmlToPdf.NetCore(18.3.0)在Dotnetcore 2.1中将HTML转换为pdf。它可以在本地环境中完美运行,但是当与Docker托管时,会引发错误消息,
{“ fileName”:“ System.TypeInitializationException:'Gdip'的类型初始值设定项引发了异常。---> System.DllNotFoundException:无法加载共享库'libdl'或其依赖项之一,以帮助诊断加载问题,请考虑设置LD_DEBUG环境变量:liblibdl:无法打开共享对象文件:Interop.Libdl.dlopen(字符串文件名,Int32标志)处没有这样的文件或目录\ n,System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary() \ n在System.Drawing.SafeNativeMethods.Gdip..cctor()\ n-内部异常堆栈跟踪的结尾--- \ n在System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr&fontCollection)\ n在SelectPdf。 Lib.?..ctor()\n在SelectPdf.Lib.?..ctor()\n在SelectPdf.Lib.?..ctor(?A_0,?A_1)\ n
在SelectPdf.HtmlToPdf.ConvertHtmlString(String htmlString)处(字符串A_0,字符串A_1,字符串A_2,字符串A_3,布尔值A_4)\ n
我尝试通过在Dockerfile中添加这些行集来进行尝试,但是仍然存在相同的错误。
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
Arkadiusz Ra..
6
我知道这是一个老问题,但是最近我遇到了这个问题,我想与我分享一下解决方案。
Select.HtmlToPdf.NetCore在linux上
不起作用。如果您已经用html生成了字符串,我建议您找到这个nuget:Haukcode.DinkToPdf
要查找一些教程,只需google DinkToPdf。Haukcode刚刚更新,并且对docker更友好。
一些dockerfile的东西:
FROM microsoft/aspnetcore:2.0.0 as Base
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y libgdiplus
RUN apt-get install -y libc6-dev
RUN ln -s /usr/lib/libgdiplus.so/usr/lib/gdiplus.dll
...
我希望它可以帮助某人:)
1> Arkadiusz Ra..:
我知道这是一个老问题,但是最近我遇到了这个问题,我想与我分享一下解决方案。
Select.HtmlToPdf.NetCore在linux上
不起作用。如果您已经用html生成了字符串,我建议您找到这个nuget:Haukcode.DinkToPdf
要查找一些教程,只需google DinkToPdf。Haukcode刚刚更新,并且对docker更友好。
一些dockerfile的东西:
FROM microsoft/aspnetcore:2.0.0 as Base
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y libgdiplus
RUN apt-get install -y libc6-dev
RUN ln -s /usr/lib/libgdiplus.so/usr/lib/gdiplus.dll
...
我希望它可以帮助某人:)