Gopi

Gopi

  • 1.4k
  • 307
  • 23k

Add header and footer to pdf generated using iText7

Jan 30 2025 3:50 PM

private byte[] GeneratePdf(string htmlString) { using (var memoryStream = new MemoryStream()) { var converterProperties = new iText.Html2pdf.ConverterProperties(); string basePath = AppDomain.CurrentDomain.BaseDirectory; converterProperties.SetBaseUri(basePath); using (var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlString))) { HtmlConverter.ConvertToPdf(htmlStream, memoryStream, converterProperties); } return memoryStream.ToArray(); } }