rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 417 forks source link

libwkhtmltox reference is invalid or unsupported ASP.Net Core 2.1 #80

Open anking opened 5 years ago

anking commented 5 years ago

When i try to make a reference for the 64 bit version of this file(libwkhtmltox.dll) in my Core 2.1 project i have this error coming up for me: image

Therefore when i publish my project I have to manually copy this dll in executables directory. Is there a way this can be fixed? Or is there a version that is compatible with core 2.1?

I downloaded mine here: https://github.com/rdvojmoc/DinkToPdf/blob/master/v0.12.4/64%20bit/libwkhtmltox.dll

fabercs commented 5 years ago

dll's in the location are compatible, I have my 2.1 core project in production with these dlls. Please check my problem I had before https://github.com/rdvojmoc/DinkToPdf/issues/25#issuecomment-477205608

anking commented 5 years ago

dll's in the location are compatible, I have my 2.1 core project in production with these dlls. Please check my problem I had before #25 (comment)

I tried your solution without any luck, i also tried downloading it from here https://github.com/wkhtmltopdf/wkhtmltopdf/ this gives a bigger (39Mb) file, but still have the same issue. VS keeps saying it is incompatible :(

cchulo commented 5 years ago

what does your .csproj look like?

I have dinktopdf working just fine, dlls and all, in a ASP.NET Core 2.1 project. In my project's .csproj i added them like:

`

PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest PreserveNewest

`

My project structure is "{solution folder}/{project folder}/v0.12.4/..."

Edit: sorry i can't make the code above look nicer Edit 2: Project structure example i posted could not be viewed

HakanL commented 5 years ago

I'm using .NET Core 2.2 and after some fixes I got it working now, including on Linux, Mac and Windows. I've forked the project here https://github.com/hakanl/DinkToPdf and also uploaded it to NuGet with all the dependencies (binaries) for wkhtmltopdf https://www.nuget.org/packages/Haukcode.DinkToPdf

simbrams commented 5 years ago

@HakanL I installed your version, it works fine locally but when I deploy it to an Azure App Service, it doesn't work anymore with the error : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) I tried to run my App service on 32 and 64 but it has no effect on the issue. Any idea ?

HakanL commented 5 years ago

Hmm, I haven't had a chance to try it on Azure, but I run it fine under Windows. It seems it would load the wrong 32/64 version. Can you try it locally (Windows) on both 32 and 64 bit and make sure the correct DLL is loaded? You can open an issue on my repo as well if you want.

simbrams commented 5 years ago

I managed to make the lib work on every OS and either 32 or 64 runtimes there: https://github.com/HakanL/DinkToPdf/issues/8

felicss commented 5 years ago

@HakanL I installed your version, it works fine locally but when I deploy it to an Azure App Service, it doesn't work anymore with the error : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) I tried to run my App service on 32 and 64 but it has no effect on the issue. Any idea ?

In my case it is working on Azure AppService for Windows

HakanL commented 5 years ago

The Azure App Service may be too restrictive, I don't know, this package is using a native library so there may be something there. Unfortunately I don't have a good way to troubleshoot this, feel free to share a solution if you can find one.

felicss commented 5 years ago

The Azure App Service may be too restrictive, I don't know, this package is using a native library so there may be something there. Unfortunately I don't have a good way to troubleshoot this, feel free to share a solution if you can find one.

My implementation is straight forward as described in the TestWebServer project. The only interesting thing to mention is, maybe, in the ObjectSettings, I am not setting a Page but a HtmlContent string. As for now, I am not having any issues on Azure AppService.

HakanL commented 5 years ago

But was that where you had to add all the binaries to your main project? The goal of this wrapper was so you don't have to add the binaries to your main project, and it works in all scenarios, except Azure App Service, for some reason.

MinaMaherNicola commented 2 years ago

Anyone came to a solution? I'm having this problem right now

HakanL commented 2 years ago

Anyone came to a solution? I'm having this problem right now

Is your issue with .NET Core 2.1, or with Azure App Services? And more importantly, are you using the old DinkToPdf, or the updated https://github.com/HakanL/WkHtmlToPdf-DotNet project?

MinaMaherNicola commented 2 years ago

Anyone came to a solution? I'm having this problem right now

Is your issue with .NET Core 2.1, or with Azure App Services? And more importantly, are you using the old DinkToPdf, or the updated https://github.com/HakanL/WkHtmlToPdf-DotNet project?

I was having problem with Azure App Service, but I used WkHtmlToPdf-DotNet and it worked flawlessly.