Broken
Broken

Reputation: 129

Adding page numbers to PDFs including the cover page

I'm trying to add a page number to the bottom of the page, which doesn't seem to work as expected.

Currently i'm using this:

<span class="page"></span>/<span class="topage"></span>

The problem with this solution is that it doesn't count the cover as a page.

So a 7 page PDF "has" 6 pages according to my code.

I'm looking for a way to include the Cover as a page, so the number is correct.

Currently i'm looking into some JS to manipulate it afterwards, but there have to me some "official" solution?

Upvotes: 0

Views: 470

Answers (1)

Broken
Broken

Reputation: 129

Solved using javascript. :)

If anyone are looking for the solution here you go:

    var x=window.location.search.substring(1).split('&');
    for (var i in x) {
        var z=x[i].split('=',2);
        vars[z[0]] = unescape(z[1]);
    }

    var pageNumberStart = parseInt(vars.page);
    var pageNumberEnd = parseInt(vars.topage);

    if (pageNumberStart != null && pageNumberEnd != null) {
        document.getElementById('page').innerHTML = pageNumberStart + 1;
        document.getElementById('topage').innerHTML = pageNumberEnd + 1;
    }

Maybe someone got the official way to do it? :D

Upvotes: 1

Related Questions