public async Task <IActionResult> SaveByHtml() { var html = @"<!DOCTYPE html> <html> <head> </head> <body> <header> <h1>This is a hardcoded test</h1> </header> <div> <h2>456789</h2> </div> </body>"; var builder = new HtmlAsPdf(); System.IO.File.WriteAllBytes("testHard.pdf", builder.GetPDF(html)); return(Ok()); }
public async Task <IActionResult> GetByHtml() { var html = @"<!DOCTYPE html> <html> <head> </head> <body> <header> <h1>This is a hardcoded test</h1> </header> <div> <h2>456789</h2> </div> </body>"; var builder = new HtmlAsPdf(); var pdf = builder.GetPDF(html); MemoryStream pdfStream = new MemoryStream(); pdfStream.Write(pdf, 0, pdf.Length); pdfStream.Position = 0; return(new FileStreamResult(pdfStream, "application/pdf")); }