2

I am developing a .net5.0 web api and i am getting the following error while using DinkToPdf:

DllNotFoundException: Unable to load DLL 'libwkhtmltox' or one of its dependencies: The specified module could not be found. (0x8007007E)

I have followed this tutorial, with a few exceptions:

  • added the service added the service, which was not done in the tutorial

    services.AddSingleton(typeof(IConverter),
             new SynchronizedConverter(new PdfTools()));
    ...
    services.AddScoped<IPdfService, PdfService>();
    
  • named the services differently, but that shouldn't matter

  • installed it via NuGet instead of Install-Package DinkToPdf

  • my project is just an API, frontend is not in C#, shouln't matter sincer the error is here:

    return this._converter.Convert(htmlToPdfDocument);
    

Did everything else like in the tutorial.

qlabfgerkaSmurf
  • 347
  • 1
  • 5
  • 20
  • check if its 32 or 64 bit and the same of your pool – Aristos Mar 26 '21 at 13:58
  • @Aristos is there a way to get it to work without installing the libraries, as they didnt mention them anywhere on the site? – qlabfgerkaSmurf Mar 26 '21 at 14:20
  • I do not know this library - I found this answer that may help you : https://stackoverflow.com/questions/55430532/dinktopdf-net-core-not-able-to-load-dll-files – Aristos Mar 27 '21 at 02:14

4 Answers4

4

What is happening there is you are missing the dlls under your project directory. enter image description here

you can get them here DinkToPdf dlls and include them in your project.

Sudi Dav
  • 51
  • 1
  • 4
4

For me adding this into the csproj file resolved the issue -

<ItemGroup>
  <None Remove="libwkhtmltox.dll" />
</ItemGroup>

<ItemGroup>
  <EmbeddedResource Include="libwkhtmltox.dll">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>
bsod_
  • 903
  • 8
  • 27
0

You can run below and it will install dlls into bin. Make sure copy those dlls into root directory

Install-Package DinkToPdfCopyDependencies -Version 1.0.8

  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31839763) – Valerij Dobler May 28 '22 at 19:48
  • no such package – Cloud Aug 10 '23 at 12:12
-1

You can also try using this package to include the dependencies: https://www.nuget.org/packages/DinkToPdfCopyDependencies

CodeHat
  • 384
  • 4
  • 14