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
367 stars 66 forks source link

Unable to load native library #61

Closed nickalbrecht closed 2 years ago

nickalbrecht commented 2 years ago

I'm still digging into this, but so far I'm not sure what the cause is yet.

I'm getting the following error when trying to use this, but only when deployed to a server to do testing. It doesn't have a problem when I run it locally within Visual Studio.

An unhandled exception occurred while processing the request.
AggregateException: One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.)
System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)

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

AggregateException: One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.)
System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)
System.Threading.Tasks.Task.Wait(int millisecondsTimeout, CancellationToken cancellationToken)
System.Threading.Tasks.Task.Wait()
WkHtmlToPdfDotNet.SynchronizedConverter.Invoke<TResult>(Func<TResult> delegate)
WkHtmlToPdfDotNet.SynchronizedConverter.Convert(IDocument document)
-- I've truncated the stack trace here for brevity -- 

NotSupportedException: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.
WkHtmlToPdfDotNet.ModuleFactory.GetModule()
WkHtmlToPdfDotNet.PdfTools.Load()
WkHtmlToPdfDotNet.BasicConverter.Convert(IDocument document)
WkHtmlToPdfDotNet.SynchronizedConverter.<>n__0(IDocument document)
WkHtmlToPdfDotNet.SynchronizedConverter+<>c__DisplayClass4_0.<Convert>b__0()
System.Threading.Tasks.Task<TResult>.InnerInvoke()
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)

It's being used on a website hosted in IIS and using .NET 6, and I'm using the SynchronizedConverter. I do see the wkhtmltox.dll, so I know that's not it. I assume that the mentioned libjpeg62 thing is for when on linux? Not sure what else would be causing this?

nickalbrecht commented 2 years ago

I KNEW as soon as I wrote this, I'd find something. 😅 For some reason, the runtimes folder is not being included in my publish, no idea why yet. But I don't think that's related to WkHtmlToPdf-DotNet