This maybe sounds "easy" but I haven't found a real solution. I need to create Pdf files from Html strings from an API on .Net Core. The library must be free (Not payments or anything related). I found that PDFSharp was a good option, but now I check out that PDFSharp is not available for .Net Core and It doesn't allow to inject a Html string.
So, PDFSharp is a good option for this case? Or what other library would you recommend me?
Thanks a lot.
I recently ran into the exact same issue myself. There is currently extremely limited ways in dealing with PDFs in general in .NET Core. To go through them...
IMO the only free one that will do what you need is SelectPDF. And that's saying something because I don't rate the library or the API. But it's free and it works.
More info : https://dotnetcoretutorials.com/2019/07/02/creating-a-pdf-in-net-core/
if anyone needs an option with this, here is the final solution that I decided to use.
var url = "https://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net";
var chromePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
var output = Path.Combine(Environment.CurrentDirectory, "printout.pdf");
using (var p = new Process())
{
p.StartInfo.FileName = chromePath;
p.StartInfo.Arguments = $"--headless --disable-gpu --print-to-pdf={output} {url}";
p.Start();
p.WaitForExit();
}
https://stackoverflow.com/a/59943987/3877537
Thanks @leonard-AB
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With