1 | var temp = require('../lib/temp'),
|
2 | fs = require('fs'),
|
3 | util = require('util'),
|
4 | path = require('path'),
|
5 | exec = require('child_process').exec;
|
6 |
|
7 | var myData = "\\starttext\nHello World\n\\stoptext";
|
8 |
|
9 | temp.mkdir('pdfcreator', function(err, dirPath) {
|
10 | var inputPath = path.join(dirPath, 'input.tex')
|
11 | fs.writeFile(inputPath, myData, function(err) {
|
12 | if (err) throw err;
|
13 | process.chdir(dirPath);
|
14 | exec("texexec '" + inputPath + "'", function(err) {
|
15 | if (err) throw err;
|
16 | fs.readFile(path.join(dirPath, 'input.pdf'), function(err, data) {
|
17 | if (err) throw err;
|
18 | util.print(data);
|
19 | });
|
20 | });
|
21 | });
|
22 | });
|