public IActionResult DownloadPdf() { try { var bundlePath = Path.Combine(_env.WebRootPath, "css", "views", "pdf.css"); var html = GetTestHtml(); var pngBinaryData = System.IO.File.ReadAllBytes(_env.WebRootFileProvider.GetFileInfo("assets/images/ais-logo.png")?.PhysicalPath); var imgDataURI = @"data:image/png;base64," + Convert.ToBase64String(pngBinaryData); html = html.Replace("/assets/images/ais-logo.png", imgDataURI); var title = $"10006-Test-Estimate"; var filename = $"{title}.pdf"; var doc = _pdfService.HtmlToPdf(html, true, StandardPrintOptions.Build(bundlePath, true, title)); return(File(doc.Stream, "application/pdf", filename)); } catch (Exception e) { return(BadRequest(e)); } }