DinkToPdf: Native library not loaded on Linux
Hi I’m having some serious issues with this package. I added the package to my project and copied the native .so file to the root of my ASP.NET Core project. Now when I start the application and try to convert HTML to PDF I get the following error:
(Exception from HRESULT: 0x8007007E)) ---> System.DllNotFoundException: Unable to load DLL 'libwkhtmltox': The specified module could not be found.
I’ve tried setting up LD_LIBRARY_PATH to my app folder. I even copied the .so file to /usr/lib but it doesn’t work at all.
Any ideas what to do here?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 28 (5 by maintainers)
@fernandovictorTI, I believe the problem is that the second stage of your build (
runtime) is not running the below command again, solibwkhtmltoxand it’s dependencies are left in the first stage (build).After install of libgdiplus in
microsoft/dotnet:1.1.2-runtimeimage libwkhtmltox library is found.Dockerfile:
Result: 636370886662487690.pdf
Thanks @Ahmed-Raouf for pointing this out.
I deployed my application on Linux and it works. But I installed libgdiplus as I needed it in Captcha component which I use in my application. I don’t know if wkhtmltopdf depends on it or not. Try to install it. Hope this fix your problem.
sudo apt-get install libgdiplus
And how do you using it in the code? I am running .NET Core 2.0 and i registered converter as:
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));and i am using it as _converter.Convert(MyDoc), injected as IConverter from constructor.
I tried to install all the suggestions from your comments, still unable to load dll in docker container.
Dockerfile:
UPDATE:
This actually works, so just use this way instead registering and adding DLL manually, as i tried before this post. Hope this helps someone…
After 4 days it worked. Thank you
this helped to me
Hi @fernandovictorTI, here’s the RUN command I used:
Results may vary depending on the source image you’re using. In my case I’m using
microsoft/dotnet:2.0-sdk-stretch.In case someone else runs into this problem when running tests (inside a Docker container or in a Linux host), adding
libgdiplusto the image didn’t do the trick for me.I checked
libwkhtmltox.sowithlddandlibgdiplusis not found as a dependency:What worked for me, for running tests, was to copy
libwkhtmltox.soto/usr/libdirectory.@miguelalvarezi Thank you for your help, I just forgot to answer that it is ok and it works.
Currently, requirenmets for pdf files were changed (need to support different headers for pages) and now I use .net core node services and nodejs html-pdf utility. I was wonder how fast it works.
For those still researching, my problem was that I was including all 3 libraries (.dll / .so / .dylib) in my .Net Core 5 WebAPI distributable on the AWS EC2 instance. Deleting 2 of them, just leaving the .so, and installing wkpdftohtml on the instance, solved the problem.
@fernandovictorTI, if you can share your Dockerfile I can review it and maybe give you some guidance.
Try to add the files: libwkhtmltox.dll libwkhtmltox.dylib libwkhtmltox.so on the root folder.
Hi,
I tried to run example DinkToPdf.TestConsoleApp on Ubuntu 16.04 LTS without problems.
Make sure that libwkhtmltox.so is placed in root folder (where your main project .dll is) of your project and is named correctly (libwkhtmltox).