UPDATE:
Seems like an issue of wkhtmltopdf not exiting properly
I'm doing the following in node:
console.log("before");
fs.writeFile(html_filename, html, function (err) {
if (err) {res.writeHead(400); res.end("" + err); return;}
console.log("wrote html fine; now converting");
exec('wkhtmltopdf ' + html_filename + ' ' + pdf_filename, function (err, stdout, stderr) {
if (err) {res.writeHead(400); res.end("" + err); return;}
console.log("converted; now reading");
fs.readFile(pdf_filename, function (err, data) {
if (err) {res.writeHead(400); res.end("" + err); return;}
console.log("read fine; now serving");
res.writeHead(200, {"content-type" : "application/pdf"});
res.end(data);
});
});
});
which works fine, except everytime this is executed, the node program hangs and when I cmd + tab I see a "exec" process. When I tab to this process, the node program proceeds.
Any ideas why?