【发布时间】:2017-11-30 07:48:43
【问题描述】:
我最近开始使用 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-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}\" 是从存储的 View 模板中提取的,该模板包含标题的图像,并且可以完美显示。问题是页脚根本不显示。
如果我删除 --header-html \"{4}\",则页脚显示得非常好。问题是我需要同时显示页眉和页脚。
任何帮助将不胜感激。
【问题讨论】:
标签: c# asp.net-mvc rotativa