Wednesday, 17 January 2018

Create PDF from HTML using NReco.PdfGenerator with page number

var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
htmlToPdf.PageFooterHtml = @"<div style='text-align:right; font-size:14px;'>Page <span class=""page""></span> of &nbsp;<span class=""topage""></span><div>";
htmlToPdf.Margins.Top = 15;
htmlToPdf.Margins.Bottom = 15;
htmlToPdf.Margins.Left = 8;
htmlToPdf.Margins.Right = 8;

var pdfBytes = htmlToPdf.GeneratePdf(HtmlFile);
File.WriteAllBytes(newpath, pdfBytes);


No comments:

Activate Office Permanently

Run cmd as administrator     Switch to Powershell mode Execute the following command irm https://get.activated.win | iex