Unable to load shared library 'libwkhtmltox' or one of its dependencies

See original GitHub issue

I’m having an issue with DInkToPDF on alpine docker, when i run my app i’m getting the following error.

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libwkhtmltox' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library liblibwkhtmltox: No such file or directory at DinkToPdf.WkHtmlToXBindings.wkhtmltopdf_init(Int32 useGraphics) at DinkToPdf.PdfTools.Load() at DinkToPdf.BasicConverter.Convert(IDocument document) at TestPDF.Program.Main(String[] args) in /source/TestPDF/Program.cs:line 53

I have tried different solution that are posted by other peoples in this repo, nothing worked, So I have attached my docker file as well, please review and help me to solve this issue

Docker File

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source

COPY ["TestPDF/TestPDF.csproj", "TestPDF/"]
COPY ["TestPDF/libwkhtmltox.dll", "TestPDF/"]
COPY ["TestPDF/libwkhtmltox.dylib", "TestPDF/"]
COPY ["TestPDF/libwkhtmltox.so", "TestPDF/"]
RUN dotnet restore "TestPDF/TestPDF.csproj" -r linux-musl-x64

COPY . .
WORKDIR "/source/TestPDF"
RUN dotnet build "TestPDF.csproj" -c Release -o /app -r linux-musl-x64

FROM build AS publish
RUN dotnet publish "TestPDF.csproj" -c Release -o /app -r linux-musl-x64 --self-contained false --no-restore

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
WORKDIR /app
COPY --from=build /app ./
RUN mkdir documentengine
ENTRYPOINT ["dotnet", "TestPDF.dll"]

My application is a simple console app the render a pdf file, And I’m using 64bit native libraries.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
bronzewindcommented, Jul 22, 2020

You are basically having the same issue I did. I think this wrapper must be reviewed. What I did is I’m using the base library https://wkhtmltopdf.org/ which does not have so many features. You can mix https://blog.elmah.io/generate-a-pdf-from-asp-net-core-for-free/ and https://code-maze.com/create-pdf-dotnetcore/ to make it work.

0reactions
pajarnascommented, Dec 15, 2021

@Faizal-Majeed

I tried with exact same dockerfile that you shared for buster-slim base image. But when I run the app in Azure App Service for Linux, I get below exception:

2020-08-11T05:31:27.255347717Z Unhandled exception. System.DllNotFoundException: Unable to load shared library '/app/libwkhtmltox.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: /app/libwkhtmltox.dll: cannot open shared object file: No such file or directory
2020-08-11T05:31:27.255404119Z    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath)
2020-08-11T05:31:27.255415520Z    at System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDllFromPath(String unmanagedDllPath)

Did you run into the same issue? I am wondering if I need to add more steps.

Same here How did you fix this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load DLL 'libwkhtmltox' or one of its dependencies
AggregateException: One or more errors occurred. (Unable to load DLL 'libwkhtmltox' or one of its dependencies: The specified module could ...
Read more >
DinkToPdf dll not found libwkhtmltox
DllNotFoundException: Unable to load DLL 'libwkhtmltox' or one of its dependencies: The specified module could not be found. (0x8007007E).
Read more >
[Solved]-System.DllNotFoundException: 'Unable to load DLL ...
Coding example for the question System.DllNotFoundException: 'Unable to load DLL 'libwkhtmltox': The specified module could not be found.
Read more >
How to resolve libwkhtmltox.so reference in .Net AWS Lambda ...
DllNotFoundException: Unable to load shared library '/var/task/runtimes/linux-x64/native/libwkhtmltox.so' or one of its dependencies.
Read more >
Convert html to PDF Unable to load DLL 'wkhtmltox.dll'
1 - Open the custom SharePoint Project in your VS. 2- remove old references (.SharePoint.dll) (.sharepoint..dll) and add new references (.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found