This commit is contained in:
@@ -114,25 +114,15 @@ namespace AyaNova.Api.Controllers
|
||||
//Add handlebars JS for compiling and presenting
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = hbspath });
|
||||
|
||||
//script
|
||||
//this works and returns the template properly
|
||||
// var theScript = $"let fun=Handlebars.compile({templateHtml});fun({dat});";
|
||||
|
||||
//cleanest way here
|
||||
var compileScript = $"Handlebars.compile({reportTemplate})({reportData});";
|
||||
|
||||
//this properly returns the function, but it doesn't work later
|
||||
// var theScript = $"''+Handlebars.compile({templateHtml});";
|
||||
|
||||
//COMPILE into function and call against data object
|
||||
//compile and run handlebars template
|
||||
var compileScript = $"Handlebars.compile({reportTemplate})({reportData});";
|
||||
var resultHTML = await page.EvaluateExpressionAsync<string>(compileScript);
|
||||
|
||||
|
||||
//open page with result
|
||||
//render report as HTML
|
||||
await page.AddStyleTagAsync(new AddTagOptions { Content = reportCSS });
|
||||
await page.SetContentAsync(resultHTML);
|
||||
|
||||
//pdf-ize and return
|
||||
//render to pdf and return
|
||||
var pdfBuffer = await page.PdfDataAsync();
|
||||
return new FileContentResult(pdfBuffer, "application/pdf");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user