driver.get('http://stackoverflow.com')
pageFormat = 'this.paperSize = {format: "A4", orientation: "portrait" };'
execute(pageFormat, [])
How to run webpage code with PhantomJS via GhostDriver (selenium)