4
我需要使用Rotativa PDF在页眉或页脚上插入一些图像。如何在Rotativa的页眉或页脚上设置图像PDF
我使用C#MVC4用剃刀
我已经尝试过: CustomSwitches = “--print-媒体类型--header中心\” 文本\ “”
我需要使用Rotativa PDF在页眉或页脚上插入一些图像。如何在Rotativa的页眉或页脚上设置图像PDF
我使用C#MVC4用剃刀
我已经尝试过: CustomSwitches = “--print-媒体类型--header中心\” 文本\ “”
如果你想在页眉/页脚中显示视图而不是文本,然后可以将图像添加到视图。
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无法访问路径。
谢谢罗杰我会试试这个。 – 2014-10-27 15:15:40