pandorafms/pandora_console/include/web2image.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-05-28 17:47:40 +02:00
var system = require('system');
if (system.args.length < 3 || system.args.length > 11) {
2018-05-28 17:47:40 +02:00
phantom.exit(1);
}
var webPage = require('webpage');
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];
var _width = system.args[7];
var _height = system.args[8];
var session_id = system.args[9];
var base_64 = system.args[10];
2018-05-28 17:47:40 +02:00
if (!_width) {
_width = 750;
}
if (!_height) {
_height = 350;
}
2018-06-01 13:58:29 +02:00
if(type_graph_pdf == 'combined'){
finish_url = url + "?" + "data=" + url_params +
"&data_combined=" + url_params_comb +
"&data_module_list=" + url_module_list +
"&type_graph_pdf=" + type_graph_pdf +
"&session_id=" + session_id;
2018-06-01 13:58:29 +02:00
}
else{
finish_url = url + "?" + "data=" + url_params +
"&type_graph_pdf=" + type_graph_pdf +
"&session_id=" + session_id;
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-01 13:58:29 +02:00
page.open(finish_url, function start(status) {
2018-06-06 17:23:32 +02:00
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