Skip to content

Instantly share code, notes, and snippets.

@masterk63
Last active July 27, 2017 22:58
Show Gist options
  • Save masterk63/a0d11e97f20052d7445e073fa1324c1e to your computer and use it in GitHub Desktop.
Save masterk63/a0d11e97f20052d7445e073fa1324c1e to your computer and use it in GitHub Desktop.
generar pdf para api node
//npm install html-pdf --save
//sudo apt-get install -y libfontconfig
// esto va si o si
exports.pdf = function(req, res, next){
var pdf = require('html-pdf');
var fs = require('fs');
var html = 'hola'
pdf.create(html).toStream(function(err, stream){
//res.setHeader('Content-Length', stat.size);
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', 'attachment; filename=quote.pdf');
stream.pipe(res);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment