如何使用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 }
};
}
在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 }
};
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句