Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
const file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname+'/../views/'+dustFile+'.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function () {
// Open and render dust file
var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function (err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function (err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname+'/../views/'+dustFile+'.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname+'/../views/'+dustFile+'.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
Promise.all(promisesData).then(function() {
// Open and render dust file
var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
dust.insertLocalsFn(dustData ? dustData : {}, req);
dust.renderSource(file, dustData || {}, function(err, rendered) {
if (err) {
console.error(err);
return res.status(500).end();
}
// Send response to ajax request
res.json({
content: rendered,
data: idSubentity || {},
empty: empty,
option: option
});
});
}).catch(function(err) {
console.error(err);
return new Promise(function (resolve, reject) {
options.data.staticImagePath = __dirname + '/../public/img';
var dustSrc = fs.readFileSync(options.file, 'utf8');
dust.insertLocalsFn(options.data ? options.data : {}, options.req);
dust.renderSource(dustSrc, options.data, function (err, html) {
if (err)
return reject(err);
var tmpFileName = __dirname + '/../' + new Date().getTime() + '' + (Math.floor(Math.random() * Math.floor(100))) + '.pdf';
var headerStartIdx = html.indexOf('');
var headerEndIdx = html.indexOf('', headerStartIdx + (''.length)) + (''.length);
var header = html.substring(headerStartIdx, headerEndIdx);
var footerStartIdx = html.indexOf('');
var footerEndIdx = html.indexOf('', footerStartIdx + (''.length)) + (''.length);
var footer = html.substring(footerStartIdx, footerEndIdx);
pdf.create(html, {
orientation: "portrait",