Google Chrome exited unexpectedly
dsgaye opened this issue · comments
Hi everybody,
I am in a project where we were using the library without problems, but one day without change the code it stopped to work and send this exception:
"Google Chrome exited unexpectedly"
Here is an example of the code in C#
var pageSettings = new PageSettings(ChromiumHtmlToPdfLib.Enums.PaperFormat.A4)
{
Landscape = false,
};
var converter = new Converter(null, null, null, true, ChromiumHtmlToPdfLib.Enums.Browser.Chrome)
{
UseOldHeadlessMode = true
};
var randomPDFFile = Path.Combine(Path.GetTempPath(), string.Concat(Guid.NewGuid().ToString(), ".pdf"));
await converter.ConvertToPdfAsync(htmlOrigen, randomPDFFile, pageSettings);
Is something wrong in the code or is a new bug with an update of Chrome?
Thanks a lot for your help and support.
Try switching to UseOldHeadLessMode = false and see what that does. In 9 of 10 cases it always has to do something with that settings.
And on what kind of environment are you using it?
Hi, thank you for the answer.
We had been tried changing UseOldHeadLessMode to false but we received the next exception:
{"Google Chrome exited unexpectedly, {exception}"}
ChromiumHtmlToPdfLib.Exceptions.ChromiumException
Here is the code:
private async Task _printLibrary(string htmlOrigen, ChromiumHtmlToPdfLib.Enums.Browser navegador)
{
var resultadoPDF = string.Empty;
var pageSettings = new PageSettings(ChromiumHtmlToPdfLib.Enums.PaperFormat.A4)
{
Landscape = false,
};
var converter = new Converter(null, null, null, true, navegador)
{
UseOldHeadlessMode = navegador.Equals(ChromiumHtmlToPdfLib.Enums.Browser.Edge)
};
var randomPDFFile = Path.Combine(Path.GetTempPath(), string.Concat(Guid.NewGuid().ToString(), ".pdf"));
await converter.ConvertToPdfAsync(htmlOrigen, randomPDFFile, pageSettings);
var binarioPDF = File.ReadAllBytes(randomPDFFile);
return Convert.ToBase64String(binarioPDF);
}
Thanks a lot for your help and support.
Are you running the code in some kind of docker container?
No, is an application in NET Core with .NET 8
Okey than I have no idea why it is failing for you.