public class HomeController : Controller
{
public IJsReportMVCService JsReportMVCService { get; }
public HomeController(IJsReportMVCService jsReportMVCService)
{
JsReportMVCService = jsReportMVCService;
}
public async Task<IActionResult> Test()
{
var docxTemplate = Convert.ToBase64String(System.IO.File.ReadAllBytes("c:\\temp\\message.docx"));
var result = await JsReportMVCService.RenderAsync(new RenderRequest
{
Template = new Template
{
Recipe = Recipe.Docx,
Engine = Engine.Handlebars,
Docx = new Docx
{
TemplateAsset = new Asset
{
Encoding = "base64",
Content = docxTemplate
}
}
},
Data = new
{
message = "Hello world"
}
});
return new FileStreamResult(result.Content, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
{
FileDownloadName = "test.docx"
};
}
}