I would like to use Rotativa.AspNetCore.ViewAsPdf("~/Views/MyView/PDF.cshtml", model)in Blazor Server the same way I do in regular ASP.NET CORE MVC apps.
I installed the "Rotativa.AspNetCore" nuget in my Blazor server project in .NET 8
Added
RotativaConfiguration.Setup(app.Environment.WebRootPath); app.UseRotativa();in Program.csCreated a "Views" folder with a PDF.cshtml view
Created a Controller I am calling via httpClient from my razor component to generate the PDF
[HttpPost("exportPDF")]public ActionResult ExportPDF(PDFModel model){ return new Rotativa.AspNetCore.ViewAsPdf("~/Views/MyView/PDF.cshtml", model) { FileName = "MyFile" + DateTime.Now.ToString("yyyyMMddHHmmss") +".pdf", PageSize = Rotativa.AspNetCore.Options.Size.A4, PageOrientation = Rotativa.AspNetCore.Options.Orientation.Portrait, PageMargins = { Left = 15, Right = 15, Top = 15 }, CustomSwitches = "--footer-center \"MyDocument +"\" --footer-right \"Page: [page]/[toPage]\" --footer-font-size \"6\"" };}And I am getting an "Object reference not set to an instance of an object." exception from the "Rotativa.AspNetCore" source.
Has anyone got this working in Blazor?