HakanL / WkHtmlToPdf-DotNet

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
GNU Lesser General Public License v3.0
366 stars 66 forks source link

Linux alpine #133

Closed a-leonid closed 1 month ago

a-leonid commented 1 month ago

Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.

WkHtmlToPdfDotNet

at WkHtmlToPdfDotNet.ModuleFactory.GetModule() at WkHtmlToPdfDotNet.PdfTools.Load() at WkHtmlToPdfDotNet.BasicConverter.Convert(IDocument document) at WkHtmlToPdfDotNet.SynchronizedConverter.<>n0(IDocument document) at WkHtmlToPdfDotNet.SynchronizedConverter.<>cDisplayClass4_0.b__0() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

HakanL commented 1 month ago

Most likely "The platform may be missing native dependencies (libjpeg62, etc)". Alpine is very lightweight so it requires a lot of dependencies to be installed. See the other issues here for guidance.

a-leonid commented 1 month ago

I tried to add such packages RUN apk update && \ apk add --no-cache \ bash \ icu-libs \ krb5-libs \ libgcc \ libintl \ libssl1.1 \ libstdc++ \ zlib \ libstdc++ \ libx11 \ libxrender \ libxext \ libssl1.1 \ libjpeg \ gcompat \ ca-certificates \ fontconfig \ freetype \ ttf-dejavu \ ttf-droid \ ttf-freefont \ ttf-liberation && \ apk add --no-cache libgdiplus --repository https://dl-3.alpinelinux.org/alpine/edge/testing/ && \ ln -s /usr/lib/libjpeg.so.8 /usr/lib/libjpeg.so.62

HakanL commented 1 month ago

I can't tell exactly what you need to do, but I know it's a lot harder with the Alpine distribution. Do you have to use that, or could you use one that is known to work? Also you can try to get the wkhtmltopdf native command-line tool to run first, the error you're getting is not actually due to this package, but it's an issue when loading the native library.

HakanL commented 1 month ago

There is a sample here: https://github.com/HakanL/WkHtmlToPdf-DotNet/tree/master/src/TestConsoleAppDockerAlpine