I am trying to pass an argument from the command line and check or uncheck a check box on my local website. If I substitute the system.args[4]
in the returnVars
function with a true
or false
it works, but the argument I pass from the command line doesn't affect the check box.
var returnVars = function(){
if (system.args.length > 4) {
console.log(system.args[4]); // this is getting the correct value from the args
return system.args[4];
}
};
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit(1);
} else {
var returnable = page.evaluate(function(r,s) {
return document.getElementById(r).checked = s;
}, 'returnable', returnVars());
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
I am using the rasterize.js example and replacing the zoom option with my own. I call it with:
phantomjs rasterize.js mywebsite.com c:\foo.pdf "letter" false