Is it possible to compile a latex document using node.js?

I am new to node.js , but I think it might be useful for an asynchronous latex compiler .

In other words, I would like to know if it might be possible and how to compile the document through node.js and pdflatex. The remote application would send the document as a JSON data structure, with the name of the template for the layout of the final document.

node.js will handle the compilation in pdf, taking the template from the file system.

Do you know something similar already exists?

+7
latex
source share
1 answer

You can create your own child processes and thus also start latex processing. By registering with the appropriate listeners, you can detect process termination or failure exit:

var sys = require('sys'), spawn = require('child_process').spawn, pdflatex = spawn('pdflatex', ['-output-directory', '/target/dir/','input.tex']); pdflatex.on('exit', function (code) { console.log('child process exited with code ' + code); }); 

EDIT: to create an intermediate latex file using the provided data, I would suggest using the node.js template engine, for example mu / mustache.

So, you can pump pieces of the template process as a stdin for your child pdflatex process.

+8
source share

All Articles