Diciamo che avere un my_footer.html piè di pagina, che contiene quanto segue:.
<!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;
}
}
['username'/*, 'topage', 'page',.. etc and any variable you would want to replace */]
.forEach(function(param) {
substitute(param);
});
}
</script>
</head>
<body onload="substitutePdfVariables()">
<span class="username"></span>
</body>
</html>
si può sostituire "nomeutente" con un certo valore:
wkhtmltopdf my_super_html.html --footer-html my_footer.html --replace "username" "Veaer"
Si noti che ho usato javascript per sostituire la variabile denominata con il mio valore.
Hai mai capito questo. Se lo hai fatto, dovresti pubblicare la risposta. –