Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

providing the compiled tex source when error occurs

  • Loading branch information...
commit 0a828d761189e0f4fb77f9b5d192a0f9e5fdb45a 1 parent 432e001
@zweifisch authored
View
1  examples/matrix.coffee
@@ -7,6 +7,7 @@ data =
render './matrix.tex', data, (err,rs)->
if err
console.log err
+ console.log rs
else
ws = fs.createWriteStream './output.pdf'
rs.pipe ws
View
3  examples/matrix.js
@@ -13,7 +13,8 @@
render('./matrix.tex', data, function(err, rs) {
var ws;
if (err) {
- return console.log(err);
+ console.log(err);
+ return console.log(rs);
} else {
ws = fs.createWriteStream('./output.pdf');
return rs.pipe(ws);
View
3  examples/matrix.tex
@@ -2,8 +2,9 @@
\usepackage{amsmath}
\begin{document}
+{{=<< >>=}}
-\title{ {{title}} }
+\title{<<title>>}
\maketitle
$
View
18 index.coffee
@@ -43,24 +43,22 @@ render = (source,data,callback)->
renderFromTemplate = (template,data,callback)->
- if callback.debug
- return template.render data
+ temp.mkdir 'xelatex',(err,dirPath)->
- temp.mkdir 'xelatex', (err, dirPath)->
-
- fs.writeFile path.join(dirPath, 'output.tex'), (template.render data),->
+ tex = template.render data
+ fs.writeFile path.join(dirPath,'output.tex'),tex,->
xelatex = new XeLatex dirPath
- xelatex.process path.join(dirPath, 'output.tex')
+ xelatex.process path.join(dirPath,'output.tex')
- xelatex.on 'done', (path)->
+ xelatex.on 'done',(path)->
readStream = fs.createReadStream path
readStream.on 'end',->
- rmdir dirPath, ->
+ rmdir dirPath,->
callback null,readStream
- xelatex.on 'error', (err)->
- callback err
+ xelatex.on 'error',(err)->
+ callback err,tex
module.exports =
View
9 index.js
@@ -79,11 +79,10 @@
};
renderFromTemplate = function(template, data, callback) {
- if (callback.debug) {
- return template.render(data);
- }
return temp.mkdir('xelatex', function(err, dirPath) {
- return fs.writeFile(path.join(dirPath, 'output.tex'), template.render(data), function() {
+ var tex;
+ tex = template.render(data);
+ return fs.writeFile(path.join(dirPath, 'output.tex'), tex, function() {
var xelatex;
xelatex = new XeLatex(dirPath);
xelatex.process(path.join(dirPath, 'output.tex'));
@@ -96,7 +95,7 @@
return callback(null, readStream);
});
return xelatex.on('error', function(err) {
- return callback(err);
+ return callback(err, tex);
});
});
});
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "node-pdf",
- "version": "0.0.2",
+ "version": "0.0.3",
"description": "pdf generation using mustache and xelatex",
"main": "index.js",
"scripts": {
Please sign in to comment.
Something went wrong with that request. Please try again.