Wkhtmltopdf.NetCore-deprecated
Wkhtmltopdf.NetCore-deprecated copied to clipboard
Failure on .NET 5.0
Hi,
On updating my code to run on .NET 5.0, the following error occurs:
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Exception: QPainter::begin(): Returned false
Exit with code 1, due to unknown error.
at Wkhtmltopdf.NetCore.WkhtmlDriver.Convert(String wkhtmlPath, String switches, String html)
at Wkhtmltopdf.NetCore.GeneratePdf.GetPDF(String html)
The same code is working fine with dotnet 3.1.
Possibly related to this https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3119 in wkhtmltopdf itself, however it is the same version of wkhtmltopdf that works with 3.1 but not 5.0.
This issue happens with dotnet on Linux. Under Windows there is no issue with .NET 5.0
Same Issue Here: CentOS 7, netcore 5, no docker
Any updates on this? Facing the same issue.
wkhtmltopdf just calls QPrinter.setOutputFilename("/dev/stdout"), so it's possible the underlying issue is deep within QPrinter/QFile and not wkhtmltopdf.
Hi, sorry for the delay, it's been a rough time for me, i will take a look into this asap
Hi, sorry for the delay, it's been a rough time for me, i will take a look into this asap
It's ok, take care of yourself.
+1 Currently using Gotenburg until this is resolved :(
Fortunately, looks like this was considered enough of a Framework issue for it to be fixed upstream:
https://github.com/dotnet/runtime/pull/47461
So It looks like there is not a Nuget version of this for .Net 5. If using .Net 5 on Windows is the only option to Fork and build it yourself?
So are there any solutions for this?
For those hosting on linux (and needing to show client something), I recommend checking out gotenberg which you can run alongside your app in a container and generate your PDFs for now. I think the fine dude maintaining this repo is dealing with IRL stuff. I'm sure he'll sort it out soon.
Yes i got it working via gotenberg.
Hi guys, as @PeterN says there seems to be a problem with .net5, from what i have seen it will be fixed in net 5.0.4, in a few days....meanwhile i have implemented an dirty and above all temporary solution https://www.nuget.org/packages/Wkhtmltopdf.NetCore/5.0.2-preview
I would recommend that only implement this version if you really really really need it.
The final version will have some new features too.
The problem in .net5 resides in the stdin and stdout only in linux, thats why in the linux part of the tool uses files and thats why i wouldnt recomend it....writing and reading files running inside a container, lets say is not optimal.
I can confirm that 5.0.2-preview works on ubuntu 20.04 with .NET 5.0.3.
Maybe it's not working the optimal way, but at least it works, which is better than nothing :)
Thanks!
@fpanaccia Thanks for the update! I'm probably going to wait for a proper release, learnt my lesson long ago from using preview builds... π
install Install-Package Rotativa.AspNetCore -Version 1.2.0-beta
set Rotativa environment variable to
RotativaConfiguration.Setup(env.WebRootPath, "/usr/bin/");
If you are on Ubuntu 20.10 or 20.04 install wkhtmlpdf.
sudo apt install wkhtmlpdf
This works for Dot Net Core 3.1 or 5.0 I have tested both.
Any news on this? π₯Ίπ
Upgrading to latest docker images 5.0.202 fixed this for myself.
Because this is issue still open, I'll note that (my 2 cents) it should be closed with the statement that the problem is no longer present (for me) with 5.0.403--but as noted by @michael-nee maybe as early as 5.0.202 or before that.
Yesterday I spent several hours of my life that I won't get back fighting a problem that required nothing more than a more recent .NET release.