I expected this command to show 1/1
at the bootom of the generated pdf but no... any idea?
wkhtmltopdf --footer-center [page]/[topage] www.google.com /tmp/foobar.pdf
Version: 0.12.2.4 on Linux
I think this issue may be due to version 0.12.2.4 otherwise, this --footer-center [page]/[topage]
command will be doing your work.
one more example i have checked that substitutePdfVariables()
is called in body onload.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
function substitutePdfVariables() {
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
function substitute(name) {
var value = getParameterByName(name);
var elements = document.getElementsByClassName(name);
for (var i = 0; elements && i < elements.length; i++) {
elements[i].textContent = value;
}
}
['frompage', 'topage', 'page', 'webpage', 'section', 'subsection', 'subsubsection']
.forEach(function(param) {
substitute(param);
});
}
</script>
</head>
<body onload="substitutePdfVariables()">
<p>Page <span class="page"></span> of <span class="topage"></span></p>
</body>
</html>
Here Docs You can find out more variables about header and footer.