Last active
August 29, 2015 14:10
-
-
Save IgorDePaula/47ef29efde8e1b5e2659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kue = require('kue') | |
, jobs = kue.createQueue(); | |
var spawn = require('child_process').spawn; | |
jobs.process('create slide', function (job, done) { | |
ppt2pdf(job.data.file, done); | |
console.log('Job', job.id, 'is process'); | |
}); | |
jobs.on('job enqueue', function (id, type) { | |
console.log('job %s got queued', id); | |
}); | |
jobs.on('job complete', function (id, result) { | |
kue.Job.get(id, function (err, job) { | |
if (err) | |
return; | |
console.log(' completed job #%d', job.id, result); | |
}); | |
}); | |
function ppt2pdf(file, done) { | |
var unoconv = spawn("unoconv", ["-f","pdf", "-o" , file + ".pdf", file]); | |
unoconv.stdout.on('data', function (data) { | |
console.log('stdout: ' + data); | |
}); | |
unoconv.stderr.on('data', function (data) { | |
console.log('stderr: ' + data); | |
}); | |
unoconv.on('close', function (code) { | |
var convert = spawn("convert", ["-resize","1200","-density","200",file + '.pdf', file + '.jpg']); | |
convert.stdout.on('data', function (data) { | |
console.log('stdout: ' + data); | |
}); | |
convert.stderr.on('data', function (data) { | |
console.log('stderr: ' + data); | |
}); | |
convert.on('close', function (code) { | |
console.log('child process exited with code ' + code); | |
done && done(0); | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment