Reputation: 103
How to use rotativa PDF to get my view in an asp.net mvc Area. In Area rotativa always return a blank PDF. Out of Area it's working fine.
I already try:
public ActionResult Report()
{
return new ViewAsPdf("Report") {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
And :
public ActionResult Report()
{
return new ViewAsPdf("Report", new { area = "Admin" }) {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
Upvotes: 1
Views: 2688
Reputation:
Specifying the full route in the viewName parameter worked for me. Not sure what your controller is, I'll assume its "Blah"
So if your route to the .cshtml is \Areas\Admin\Views\Blah\Report.cshtml then use:
public ActionResult Report()
{
return new ViewAsPdf("~\Areas\Admin\Views\Blah\Report.cshtml") {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
Upvotes: 4