public async Task <IActionResult> MakePdf([FromBody] HtmlToPdfRequest htmlToPdfRequest) { var cacheId = Guid.NewGuid(); var pdfArguments = new PdfArguments("someFileName.pdf") { Orientation = htmlToPdfRequest.Orientation, ViewModel = htmlToPdfRequest.PdfBody, Margins = htmlToPdfRequest.Margins }; if (!string.IsNullOrWhiteSpace(htmlToPdfRequest.PdfHeader)) { CacheHeader(cacheId, htmlToPdfRequest.PdfHeader); pdfArguments.Header = new PdfHeader() { HtmlSourcePath = Url.Action(nameof(GetHeader), ControllerName, new { cacheId = cacheId }, Request.Scheme) }; } if (!string.IsNullOrWhiteSpace(htmlToPdfRequest.PdfFooter)) { CacheFooter(cacheId, htmlToPdfRequest.PdfFooter); pdfArguments.Footer = new PdfFooter() { HtmlSourcePath = Url.Action(nameof(GetFooter), ControllerName, new { cacheId = cacheId }, Request.Scheme) }; } var fileData = await PdfGenerator.GeneratePdfAsync(pdfArguments, ControllerContext); return(Ok(fileData)); }
public async Task <IActionResult> FooReportAsPdfPortrait() { var pdfArguments = new PdfArguments("someFileName.pdf") { ViewName = "FooReport", Orientation = Orientation.Portrait }; var fileData = await PdfGenerator.GeneratePdfAsync(pdfArguments, ControllerContext); return(Ok(fileData)); }