-
Notifications
You must be signed in to change notification settings - Fork 0
/
phantom.js
30 lines (29 loc) · 1.14 KB
/
phantom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var page = require('webpage').create();
var fs = require('fs');
var workingDir = fs.workingDirectory;
var args = require('system').args;
var readfile = args[1];
var writefileloc = args[2];
page.open('file:///' + workingDir + '/public/sample.html', function (status) {
if (status !== 'success') {
console.log('file:///' + workingDir + '/public/sample.html');
console.log('Unable to access network');
} else {
readfile = args[1];
var content = fs.read(readfile);
var ua = page.evaluate(function (content) {
var diagram = $("#diagram").ejDiagram("instance");
diagram.load(JSON.parse(content));
return new XMLSerializer().serializeToString(diagram.exportDiagram({
fileName: "digram", region: "pageSettings", format: "svg", mode: "data",
}));
}, content);
var dir = "C:/Users/kameshwaranr/Desktop/nodeJS/nodeExpress/myapp/outputfiles"
dir = writefileloc;
if (fs.makeTree(dir)) {
fs.write(dir + "/" + "sample.svg", ua, 'w');
}
console.log(dir + "/" + "sample.svg was created");
}
phantom.exit();
});