2014-10-01 54 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

相关问题