Reputation: 37
I'm developing a .NET 7.0 web application with Visual Studio 2022 ver 17.7.5
I need to convert an Html View into a PDF.
To do so, I want to use Rotativa, which seems to be a very powerful and simple usage tool.
I followed several tutos on the web (they are not missing!!) and everything seems very simple.
I ran some testing onto a dummy application, so there's nothing complex in it, I'm just trying to convert the index.cshtml file.
I've installed Rotativa.AspNetCore 1.3.2 beta nuget package,
I've also installed the wkhtmltopdf tool in my solution.
Here is my controller:
[HttpGet]
public IActionResult Index()
{
_index = new List<Customer>()
{
new Customer {CustomerId = 1, FirstName = "Jimi",
LastName = "Hendrix" },
new Customer {CustomerId = 2,FirstName = "Mitch", LastName = "Mitchell"}
};
return View(_index);
}
public ActionResult Print()
{
return new ViewAsPdf("Index", _index);
}
The Index view:
@Html.ActionLink("Print", "Print", "home")
With this code, I get the following error message:
ArgumentNullException: Value cannot be null. (Parameter 'RotativaPath')
I've searched the whole web, and neither Google, nor Stackoverflow seem to have solution.
I don't know if there's a compatibility issues with Rotativa, a setting wrongly configured or missing, or a problem with the appsettings.json but all I've tried failed so far...
Even ChatGPT advised me to ask Stackoverflow for help.
Anyone has a hint for help?
Upvotes: 1
Views: 692
Reputation: 3037
I'm the package owner.
You'll have to add this in Program.cs:
app.UseRotativa();
Instructions are in the Readme file of the beta version you installed and in the Github repository readme https://github.com/webgio/Rotativa.AspNetCore.
Upvotes: 2