0

I am using Aspnet mvc and .NET rotativa to convert html to pdf. I am using CustomSwitches to display paging in PDF footer as the example [here

@{ 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>

but when generating the report in PDF, does not appear the page of the last page, someone has gone through it and found a solution?

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94

1 Answers1

2

I managed to solve my problem by adding the following code:

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

Something like this for a full example:

        return new ViewAsPdf("MyAction", Model) {

            FileName = "somepdf.pdf",
            WkhtmlPath = "~/Rotativa"
            ,CustomSwitches = "--footer-right \"[page]/[topage]\""
        };
Sha
  • 2,185
  • 1
  • 36
  • 61