Created
February 11, 2019 19:29
-
-
Save nicoavila/6dda8beb532aa2da4e6e98a4ddca1c27 to your computer and use it in GitHub Desktop.
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
/* | |
* ADVERTENCIA: | |
* - Asume el uso de Angular | |
*/ | |
public descargarCertificado() { | |
this.http.get('/genera_certificado', { | |
responseType: 'arraybuffer' | |
}).subscribe((data:any) => this.descargarArchivo(data)); | |
} | |
public descargarArchivo(datos: any) { | |
const blob = new Blob([data], {type: 'application/pdf'}); | |
const url = window.URL.createObjectURL(blob); | |
window.open(url); | |
} |
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
/* | |
* ADVERTENCIA: | |
* - Esto asume la instalación de WKHTMLTOPDF en el servidor (binario agregado al PATH) | |
* - Asume el uso de express. Esto es solo una ruta de ejemplo | |
*/ | |
const wkhtmltopdf = require('wkhtmltopdf'); | |
router.get('/genera_certificado', (req, res) => { | |
const body = '<p>Hola! Soy HTML</p>'; | |
wkhtmltopdf(body , options).pipe(res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment