如何使用rotativa PDF在asp.net mvc区域中获取我的视图。在区域中,rotativa始终返回空白PDF。离开区域它工作正常。
我已经尝试过了:
public ActionResult Report()
{
return new ViewAsPdf("Report") {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
并且:
public ActionResult Report()
{
return new ViewAsPdf("Report", new { area = "Admin" }) {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
答案 0 :(得分:2)
在viewName参数中指定完整路径为我工作。不确定你的控制器是什么,我会假设它是" Blah"
因此,如果您到.cshtml的路线是\ Areas \ Admin \ Views \ Blah \ Report.cshtml,那么请使用:
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 }
};
}