Reputation: 610
All the content I need to show in a pdf is in the database as encoded html. Is there a c# library that can take html and generate pdf file?
I tried https://htmlrenderer.codeplex.com/ but it has the following issues: Only first 4 pages show, remaining are blank. The text gets cut off at page break.
Thanks in advance.
Upvotes: 1
Views: 789
Reputation: 610
I ended up using http://www.nrecosite.com/pdf_generator_net.aspx, which perfectly fit my requirements.
I am using it in an ASP.Net MVC project, 3 lines of code did it.
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
byte[] pdfBytes = htmlToPdf.GeneratePdf(htmlString);
return File(pdfBytes, "application/pdf");
Its available in nuget: https://www.nuget.org/packages/NReco.PdfGenerator/
Upvotes: 2