I created a sample application in which I used the nuget package HtmlRenderer.PdfSharp
I used the code below in my console application to generate PDF from HTML:
string input = File.ReadAllText("..//..//HTML//dfdf.html"); PdfDocument document = new PdfDocument(); document.Info.Title = "Test"; PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always); // Create a font TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerateConfig pdfconfg = new TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerateConfig(); pdfconfg.PageSize = PdfSharp.PageSize.A4; document = PdfGenerator.GeneratePdf(input, pdfconfg); document.Save("..//..//PDF//dfdf.pdf");
But when the text of the html page is very long, it does not render the content. Only blank pages are generated. Please help. I want to use this library as it provides the desired output.
source share