Suppose you have my_footer.html footer that contains the following:
<!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'] .forEach(function(param) { substitute(param); }); } </script> </head> <body onload="substitutePdfVariables()"> <span class="username"></span> </body> </html>
You can replace "username" with some value:
wkhtmltopdf my_super_html.html --footer-html my_footer.html --replace "username" "Veaer"
Note that I used javascript to replace the named variable with my value.
source share