currently I am working on an automatic docx2pdf converter in node.js. I am using unoconv. When i run this command in the shell in works pretty well:
unoconv -f pdf "/opt/bitnami/apache2/htdocs/123.docx"
But i want to call this command from node.js, there are some modules (unoconv wrapper), but none of this worked for me. So i just want to call this command from above. I tried all solutions from node.js shell command execution but they dont work.
Why does this code snippet doesent work for me?
function run_cmd(cmd, args, callBack) {
var spawn = require('child_process').spawn;
var child = spawn(cmd, args);
var resp = "";
child.stdout.on('data', function(buffer) {
resp += buffer.toString()
});
child.stdout.on('end', function() {
callBack(resp)
});
} // ()
run_cmd("unoconv", ['-f pdf "/opt/bitnami/apache2/htdocs/123.docx"'], function(text) {
console.log(text)
});
It dont produced output even if i run the script from pm2 as service or directly with the node command. I hope you can help me! Thanks in advance