-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnode-latex-pdf.js
27 lines (25 loc) · 966 Bytes
/
node-latex-pdf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { exec } = require('child_process');
const path = require('path');
const fs = require('fs');
const os = require('os');
var selflatex = function(src_file,dest_file,callback){
// split with src file name
var texname = src_file.split('/').splice(-1)[0].split('.')[0];
// compile and
exec("pdflatex -output-directory " + dest_file + " " + src_file, (err,stdout,stderr) => {
if (err) {
callback(1,`pdflatex[1] error: ${err}`);
}else{
// compile second time to fit the usage
exec("pdflatex -output-directory " + dest_file + " " + src_file, (err,stdout,stderr) => {
if (err) {
callback(1,`pdflatex[2] error: ${err}`);
}
else{
callback(0,`[node-latex-complete] Complete source: ${src_file}, check out result in ${dest_file}!`);
}
});
}
});
}
module.exports = selflatex