HTMLtoPdf for .net core 3.1 - Converts HTML content to PDF using chrome executable
Satish Patil
Posted on October 2, 2021
Note : Requires Chrome executable
Nuget Link -https://www.nuget.org/packages/Sats.Core.HTMLToPdf
var url = @"d:\test.html";
var chromePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
var output = new ChromeOptions().AddOptions(b =>
{
b.Headless();
b.DisableGPU();
b.WithoutHeader();
}).ToPdf(new ChromeDetails()
{
ChromePath = chromePath,
HtmlPath = url,
DeleteOutputFile = true, //optional
// OutputPath = @"d:\print.pdf" // (add if Environment.CurrentDirectory does not have access rights)
});
File.WriteAllBytes(@"d:\print.pdf", output.FileDetails.File);
💖 💪 🙅 🚩
Satish Patil
Posted on October 2, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.