我正在使用以下代码在 selectPDF 中创建标题。
string headerUrl = ViewToHtmlAsync("~/Views/HeaderTemplate/Header.cshtml");
PdfHtmlSection headerHtml = new PdfHtmlSection(headerUrl,"https://selectpdf.com/demo/files/header.html");
converter.Header.Add(headerHtml);
ViewToHtmlAsync 是将 .cshtml 文件转换为 html 字符串的函数。Header.cshtml 将生成以下模板。
但目前页码数据“1 of 2”是硬编码的。
我的问题是如何将页码从控制器传递给 Header.cshtml 并将其放入表格中,以便在每个页面上获得正确的页码数据?似乎只有占位符 {page_number} 和 {total_pages} 可以生成页码?如果是,我如何将它传递到我的 Header.cshtml 中?谢谢你的帮助。