2018-05-28 17:47:40 +02:00
|
|
|
var system = require('system');
|
|
|
|
|
2018-06-08 08:58:18 +02:00
|
|
|
if (system.args.length < 3 || system.args.length > 11) {
|
2018-05-28 17:47:40 +02:00
|
|
|
phantom.exit(1);
|
|
|
|
}
|
|
|
|
|
2018-06-19 19:07:36 +02:00
|
|
|
var webPage = require('webpage');
|
2018-05-28 17:47:40 +02:00
|
|
|
var page = webPage.create();
|
|
|
|
var url = system.args[1];
|
2018-06-01 13:58:29 +02:00
|
|
|
var type_graph_pdf = system.args[2];
|
|
|
|
var url_params = system.args[3];
|
|
|
|
var url_params_comb = system.args[4];
|
|
|
|
var url_module_list = system.args[5];
|
|
|
|
var output_filename = system.args[6];
|
2018-06-19 19:07:36 +02:00
|
|
|
var viewport_width = system.args[7];
|
|
|
|
var viewport_height = system.args[8];
|
2018-06-08 08:58:18 +02:00
|
|
|
var session_id = system.args[9];
|
|
|
|
var base_64 = system.args[10];
|
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
|
2018-06-19 19:07:36 +02:00
|
|
|
if (!viewport_width) {
|
|
|
|
viewport_width = 750;
|
2018-05-28 17:47:40 +02:00
|
|
|
}
|
|
|
|
|
2018-06-19 19:07:36 +02:00
|
|
|
if (!viewport_height) {
|
|
|
|
viewport_height = 350;
|
2018-05-28 17:47:40 +02:00
|
|
|
}
|
|
|
|
|
2018-06-01 13:58:29 +02:00
|
|
|
if(type_graph_pdf == 'combined'){
|
2018-06-19 19:07:36 +02:00
|
|
|
post_data = "data=" + url_params +
|
|
|
|
"&data_combined=" + url_params_comb +
|
|
|
|
"&data_module_list=" + url_module_list +
|
|
|
|
"&type_graph_pdf=" + type_graph_pdf +
|
2018-06-19 19:19:38 +02:00
|
|
|
"&session_id=" + session_id +
|
|
|
|
"&viewport_width=" + viewport_width;
|
2018-06-01 13:58:29 +02:00
|
|
|
}
|
|
|
|
else{
|
2018-06-19 19:07:36 +02:00
|
|
|
post_data = "data=" + url_params +
|
|
|
|
"&type_graph_pdf=" + type_graph_pdf +
|
2018-06-19 19:19:38 +02:00
|
|
|
"&session_id=" + session_id +
|
|
|
|
"&viewport_width=" + viewport_width;
|
2018-06-01 13:58:29 +02:00
|
|
|
}
|
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
page.viewportSize = { width: _width, height: _height };
|
2018-05-30 17:45:17 +02:00
|
|
|
//page.zoomFactor = 1.75;
|
2018-05-28 17:47:40 +02:00
|
|
|
|
2018-06-19 19:07:36 +02:00
|
|
|
page.open(post_data, 'POST', post_data, function start(status) {});
|
2018-06-06 11:18:39 +02:00
|
|
|
|
|
|
|
page.onLoadFinished = function (status) {
|
2018-06-06 17:23:32 +02:00
|
|
|
if(!base_64){
|
|
|
|
page.render(output_filename, {format: 'png'});
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
var base64 = page.renderBase64('png');
|
|
|
|
console.log(base64);
|
|
|
|
}
|
2018-05-28 17:47:40 +02:00
|
|
|
phantom.exit();
|
2018-06-06 11:18:39 +02:00
|
|
|
}
|
2018-05-28 17:47:40 +02:00
|
|
|
|
|
|
|
|