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(); } }