2014-10-01 169 views

回答

5

如果你想在頁眉/頁腳中顯示視圖而不是文本,然後可以將圖像添加到視圖。

public ActionResult ViewPDF() 
{ 
     string cusomtSwitches = string.Format("--print-media-type --allow {0} --footer-html {0}" 
       Url.Action("Footer", "Document", new { area = ""}, "https")); 


    return new ViewAsPdf("MyPDF.cshtml", model) 
       { 
        FileName = "MyPDF.pdf", 
        CustomSwitches = customSwitches 
       }; 
} 

[AllowAnonymous] 
public ActionResult Footer() 
{ 
    return View(); 
} 

不要忘記在頁腳動作中添加[AllowAnonymous]屬性,否則Rotatina無法訪問路徑。

+0

謝謝羅傑我會試試這個。 – 2014-10-27 15:15:40

相關問題