我試圖在由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