Skip to content

Commit

Permalink
Add lib to generate pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaís Paz committed Jan 15, 2021
1 parent cc33915 commit e3887ab
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/boleto.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,21 @@ Boleto.prototype.renderHTML = function (callback) {

renderOptions['boleto']['linha_digitavel_hash'] = hashString(renderOptions['boleto']['linha_digitavel']).toString()

ejs.renderFile(path.join(__dirname, '/../assets/layout.ejs'), renderOptions, {
var file = ejs.renderFile(path.join(__dirname, '/../assets/layout.ejs'), renderOptions, {
cache: true
}, function (err, html) {
if (err) {
throw new Error(err)
}

callback(html)
})
});

let options = { format: 'A4' };

html_to_pdf.generatePdf(file, options).then(pdfBuffer => {
console.log("PDF Buffer:-", pdfBuffer);
});
}

module.exports = function (_banks) {
Expand Down
Loading

0 comments on commit e3887ab

Please sign in to comment.