convert pptx/ppt/docx/doc to images

meteorhacks:npm

npm-container
Meteor.startup(function () {
var fs = Npm.require("fs");
var path = Npm.require('path');
var sys = Npm.require('sys');
var exec = Npm.require('child_process').exec;
var child;

var dir = "/home/bhavesh";

fs.watch(dir, {persistent: true}, function (event, fileName) {
console.log("dfs");
console.log("Event: " + event);
console.log(fileName + "\n");
var ext = path.extname(fileName);
if ((ext.toString() == ".pptx" || ext.toString() == ".ppt" || ext.toString() == ".docx" || ext.toString() == ".doc") && event == "change") {
console.log("Powerpoint file");
ppt_or_doc_to_pdf(dir,fileName);
}
if (ext.toString() == ".pdf" && event == "change") {
console.log("PDF file");
pdf_to_ppm(dir,fileName);
}
});
function pdf_to_ppm(dir, file) {
var cmd = "cd " + dir + "; pdftoppm '" + file + "' slide";
exec(cmd, function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
ppm_to_jpg(dir);
});
}

function ppt_or_doc_to_pdf(dir, file) {
var fileName = file.substring(0, file.indexOf('.'));
var cmd = "cd " + dir + "; unoconv -f pdf -o '" + fileName + ".pdf' '" + file + "'";
exec(cmd, function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
pdf_to_ppm(dir, fileName + '.pdf');
});
}
function ppm_to_jpg(dir) {
var cmd = "cd " + dir + "; mogrify -format jpg slide*.ppm";
exec(cmd, function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
}
});
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.