ASP.NET Core 6 Export PDF

Viewed 97

I want to make PDF export from my razor page in ASP.NET Core 6. I used 'Rotativa.AspNetCore'.

In my controller, I use this code:

public IActionResult PdfReport()
{
    return View();
}

And call action with this:

public ActionResult Export()
{
    return new ViewAsPdf("PdfReport")
               {
                   FileName = "test.pdf",
                   PageMargins = { Left = 20, Bottom = 20, Right = 20, Top = 20 },
               };
}  

After used this code in Program.cs:

IWebHostEnvironment env = app.Environment;
RotativaConfiguration.Setup((Microsoft.AspNetCore.Hosting.IHostingEnvironment)env);

I get this error:

Win32Exception: An error occurred trying to start process 'D:\Projects\WebApp\AvatWebApp\AvatWebApp\wwwroot\Rotativa\wkhtmltopdf.exe' with working directory 'D:\Projects\WebApp\AvatWebApp\AvatWebApp\wwwroot\Rotativa'. The requested operation requires elevation.

Please help me - what do I need to do?

Thanks.

1 Answers
Related