我试图在由Rotativa库生成的PDF中指定页眉和页脚。由于作者回答here,应该可以使用CSS(描述为here)。但是,我无法做到这一点。在Rotativa生成的PDF中显示页眉和页脚
我在meta标签加载的样式表:
<link href="print.css" rel="stylesheet" type="text/css" media="print" />
而在底部的样式表:
public ActionResult ShowPdf()
{
var model = new Model();
return new ViewAsPdf("view.cshtml", model)
{
FileName = "Report.pdf",
CustomSwitches = "--print-media-type"
};
}
和:
@page {
@top-left {
content: "TOP SECRET";
color: red
}
@bottom-right {
content: counter(page);
font-style: italic
}
}
然后通过生成PDF那么PDF的页眉和页脚中将不会显示任何内容。有任何想法吗?
只是测试,你不需要' --print-media-type' – Kendrome 2015-10-28 15:33:03