Last active
July 27, 2017 22:58
-
-
Save masterk63/a0d11e97f20052d7445e073fa1324c1e to your computer and use it in GitHub Desktop.
generar pdf para api node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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