【问题标题】:rotativa pdf doesn't show last pagerotativa pdf不显示最后一页
【发布时间】:2015-05-25 16:32:13
【问题描述】:

我正在使用 Aspnet mvc 和 .NET rotativa 将 html 转换为 pdf。 我正在使用 CustomSwitches 在 PDF 页脚中显示分页作为示例 [这里

@{ Layout = null;}
<!DOCTYPE html>
<html>
<head>
    <script>
        function subst() {
            var vars = {};
            var x = document.location.search.substring(1).split('&');
            for (var i in x) { var z = x[i].split('=', 2); vars[z[0]] = unescape(z[1]); }
            var x = ['frompage', 'topage', 'page', 'webpage', 'section', 'subsection', 'subsubsection'];
            for (var i in x) {
                var y = document.getElementsByClassName(x[i]);
                for (var j = 0; j < y.length; ++j) y[j].textContent = vars[x[i]];
            }
        }

    </script>
</head>
<body style="border:0; margin: 0;" onload="        subst()">
    <table style=" width: 100%">
        <tr>
            <td class="section"></td>
            <td style="text-align:right">
                <span class="page"></span> / <span class="topage"></span>
            </td>
        </tr>
    </table>
</body>
</html>

但是在生成PDF报告时,没有出现最后一页的页面,有人浏览过,找到了解决办法?

【问题讨论】:

    标签: pdf rotativa


    【解决方案1】:

    我设法通过添加以下代码解决了我的问题:

    CustomSwitches = "--footer-right \"[page]/[topage]\""
    

    一个完整的例子是这样的:

            return new ViewAsPdf("MyAction", Model) {
    
                FileName = "somepdf.pdf",
                WkhtmlPath = "~/Rotativa"
                ,CustomSwitches = "--footer-right \"[page]/[topage]\""
            };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 2021-01-18
      • 2012-12-19
      • 2016-12-07
      相关资源
      最近更新 更多