Example #1
0
        public async Task <IActionResult> UpdateAndGetFromEngine()
        {
            var data = new TestData
            {
                Text   = "This is a test",
                Number = 123456
            };

            if (!_generatePdf.ExistsView("notAView"))
            {
                var html = await System.IO.File.ReadAllTextAsync("Views/Test.cshtml");

                _generatePdf.AddView("notAView", html);
            }
            else
            {
                var html = @"@model Rotativa.Models.TestData
                        <!DOCTYPE html>
                        <html>
                        <head>
                        </head>
                        <body>
                            <header>
                                <h1>@Model.Text</h1>
                            </header>
                            <div>
                                <h2>Repeat @Model.Text</h2>
                            </div>
                            <div>
                                <h5>@Model.Number</h2>
                            </div>
                        </body>
                        </html>";

                _generatePdf.UpdateView("notAView", html);
            }

            return(await _generatePdf.GetPdf("notAView", data));
        }