From d9e70e5abdc7959d0867a03b95536719d7bf6d24 Mon Sep 17 00:00:00 2001 From: Christian Haschek Date: Thu, 1 Oct 2015 15:36:32 +0200 Subject: [PATCH] phantom render script --- phantom.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 phantom.js diff --git a/phantom.js b/phantom.js new file mode 100644 index 0000000..7124e70 --- /dev/null +++ b/phantom.js @@ -0,0 +1,29 @@ +var page = require('webpage').create(), + system = require('system'), + address, output, size; + +var input = system.args[1].split(","); + +address = input[0]; +output = input[1]; +var vp_w = input[2]; +var vp_h = input[3]; +var js = input[4]; + +var pageWidth = (vp_w!="")?parseInt(vp_w, 10):1024; +var pageHeight = (vp_h!="")?parseInt(vp_h, 10):'auto'; +page.viewportSize = { width: pageWidth, height: pageHeight }; +page.clipRect = { top: 0, left: 0, width: pageWidth, height: pageHeight }; +page.settings['javascriptEnabled'] = (js=="no")?false:true; + + page.open(address, function (status) { + if (status !== 'success') { + console.log('Unable to load the address!'); + phantom.exit(1); + } else { + window.setTimeout(function () { + page.render(output); + phantom.exit(); + }, 200); + } + }); \ No newline at end of file