-
Notifications
You must be signed in to change notification settings - Fork 8
/
ppt2png.js
56 lines (48 loc) · 1.36 KB
/
ppt2png.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var exec = require('child_process').exec,
fs = require('fs');
var ppt2png = function(input, output, callback) {
exec('unoconv -f pdf -o ' + output + '.pdf ' + input,
function( error, stdout, stderr) {
if (error) {
callback(error);
return;
}
pdf2png(output+'.pdf', output, function(err){
fs.unlink(output+'.pdf', function(err) {
if(err) {
console.log(err);
}
});
callback(err);
});
});
}
var pdf2png = function(input, output, callback) {
exec('convert -resize 1200 -density 200 ' + input + ' ' + output+'.png',
function (error, stdout, stderr) {
if (error) {
callback(error);
} else {
callback(null);
}
});
}
// ppt to jpg by unoconv directly
var ppt2jpg = function(input, output) {
exec('unoconv -f html -o ' + output + '/ ' + input,
function( error, stdout, stderr) {
console.log('unoconv stdout: ', stdout);
console.log('unoconv stderr: ', stderr);
if (error !== null) {
console.log('unoconv err: ', error);
} else {
exec('rm ' + output + '/*.html ' + output + '/' + output,
function(){
if(error !== null) {
console.log('rm err: ', error);
}
});
}
});
}
module.exports = ppt2png;