Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Failure on .NET 5.0 #46

Open
PeterN opened this issue Dec 21, 2020 · 18 comments
Open

Failure on .NET 5.0 #46

PeterN opened this issue Dec 21, 2020 · 18 comments

Comments

@PeterN
Copy link

PeterN commented Dec 21, 2020

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 wkhtmltopdf/wkhtmltopdf#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

@fjsosa
Copy link

fjsosa commented Dec 29, 2020

Same Issue Here: CentOS 7, netcore 5, no docker

@yakeer
Copy link

yakeer commented Jan 12, 2021

Any updates on this?
Facing the same issue.

@PeterN
Copy link
Author

PeterN commented Jan 12, 2021

wkhtmltopdf just calls QPrinter.setOutputFilename("/dev/stdout"), so it's possible the underlying issue is deep within QPrinter/QFile and not wkhtmltopdf.

@fpanaccia
Copy link
Owner

Hi, sorry for the delay, it's been a rough time for me, i will take a look into this asap

@michael-nee
Copy link

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.

@lordplagus02
Copy link

+1
Currently using Gotenburg until this is resolved :(

@PeterN
Copy link
Author

PeterN commented Jan 31, 2021

Fortunately, looks like this was considered enough of a Framework issue for it to be fixed upstream:

dotnet/runtime#47461

@runxc1
Copy link

runxc1 commented Feb 9, 2021

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?

@avivCodhen
Copy link

So are there any solutions for this?

@lordplagus02
Copy link

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.

@michael-nee
Copy link

Yes i got it working via gotenberg.

@fpanaccia
Copy link
Owner

fpanaccia commented Feb 22, 2021

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.

@yakeer
Copy link

yakeer commented Feb 22, 2021

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!

@lordplagus02
Copy link

@fpanaccia Thanks for the update!
I'm probably going to wait for a proper release, learnt my lesson long ago from using preview builds... 😋

@ne0rrmatrix
Copy link

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.

@lordplagus02
Copy link

Any news on this? 🥺🙏

@michael-nee
Copy link

Upgrading to latest docker images 5.0.202 fixed this for myself.

@WellspringCS
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants