C# Rotativa显示HTML页眉和页脚
我最近开始使用Rotativa,工作非常出色!尝试配置C# Rotativa显示HTML页眉和页脚,c#,asp.net-mvc,rotativa,C#,Asp.net Mvc,Rotativa,我最近开始使用Rotativa,工作非常出色!尝试配置PDF文档的页眉和页脚除外 string customSwitches = string.Format("--header-html \"{4}\" --footer-left \"{0} {1} - {2}\" --footer-center \"{3}\" --footer-right \"Page: [page]/[toPage]\" --footer-line --footer-font-size \"9\" --footer-spa
PDF
文档的页眉和页脚除外
string customSwitches = string.Format("--header-html \"{4}\" --footer-left \"{0} {1} - {2}\" --footer-center \"{3}\" --footer-right \"Page: [page]/[toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 6", "Billing Report", FromDate.Value.ToString("yyyy-MM-dd"), ToDate.Value.ToString("yyyy-MM-dd"), customerData.Name, Url.Action("BillingRunHeader", "Report", new { area = "Admin" }, "http"));
var actionResult = new ViewAsPdf("_BillingRunPDF", GetBillingReport(UserFilterReport, ProductFilterReport, ProjectFilterReport, CustomerFilterReport.Where(x => x == customer).ToArray(), TypeFilterReport, ReportType, FromDate, ToDate, Billable, TaskId).ToList())
{
PageSize = Size.A4,
PageOrientation = Orientation.Landscape,
FileName = customerData.Name.Replace(" ","_") + "_Billing_Report_" + DateTime.Now.Date.ToString("yyyy-MM-dd") + ".pdf",
CustomSwitches = customSwitches
};
上面我创建了一个字符串格式,用数据替换某些占位符。--header html\“{4}\”
是从存储的视图
模板中提取出来的,该模板包含一个头部图像,并且显示得非常完美。问题是页脚根本不显示
如果我删除--header html\“{4}\”
,那么页脚显示得非常好。问题是我需要同时显示页眉和页脚
任何帮助都将不胜感激。对我来说,只有在用HTML离开页眉和页脚后,它才起作用
return new ViewAsPdf
{
ViewName = "RptVistoriador",
PageSize = Rotativa.Options.Size.A4,
Model = lstVistoriadorRptViewModel.ToPagedList(1, lstVistoriadorRptViewModel.Count()),
CustomSwitches = $"--footer-html \"{Url.Action("ReportHeader", "Vistoriador", new { area = "" }, "http")}\" --header-html \"{Url.Action("ReportHeader", "Vistoriador", new { area = "" }, "http")}\""
};
对我来说,它只有在用HTML离开页眉和页脚后才起作用
return new ViewAsPdf
{
ViewName = "RptVistoriador",
PageSize = Rotativa.Options.Size.A4,
Model = lstVistoriadorRptViewModel.ToPagedList(1, lstVistoriadorRptViewModel.Count()),
CustomSwitches = $"--footer-html \"{Url.Action("ReportHeader", "Vistoriador", new { area = "" }, "http")}\" --header-html \"{Url.Action("ReportHeader", "Vistoriador", new { area = "" }, "http")}\""
};