Hello,
I have a script that runs customization on a page. It targets 2 scenarios: for regular browsing and during pdf creation. I solved this problem by checking on the window.location.href property.
...
mode: /^http/.test(window.location.href) ? 'normal' : 'wkhtmltopdf'
...
During pdf creation, an HTML file is generated on the server side, passed to wkhtmltopdf, then deleted. And since wkhtmltopdf reads it locally, it will have file:///xxxxx as window.location.href
However, I'm not really satisfied with this. I prefer a more robust solution. So I discovered --custom-header but for the life of me I can't seem to get it working.
I logged the results with this script
for (var prop in navigator) {
console.log(prop + ":" + navigator[prop]);
}
ran the wkhtmltopdf (0.12.0) with these parameters:
wkhtmltopdf --debug-javascript --custom-header 'User-Agent' 'meow' --custom-header-propagation meow.html meow.pdf
and none of the object properties shows 'meow' in it.
Is this a bug or am I looking into the wrong object?