2016-12-13 46 views
0

如何使用rotativa PDF在asp.net mvc區域中獲取我的視圖。在區域rotativa總是返回一個空白PDF。超出區域它工作正常。如何使用Rotativa PDF獲取Asp.Net MVC AREA的視圖?

我已經嘗試:

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

中的viewName參數爲我工作指定完整路徑。不知道你的控制器是什麼,我會認爲它的「嗒嗒」

所以,如果你的.cshtml路線\區\管理\查看\布拉赫\ 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 } 
    }; 
} 
相關問題