-
-
Save parzibyte/61841216981b9e7adc29dc7986eaf83a 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
/** | |
* https://parzibyte.me/blog | |
*/ | |
const pdf = require("html-pdf"); | |
const fs = require("fs"); | |
const ubicacionPlantilla = require.resolve("./plantilla.html"); | |
let contenidoHtml = fs.readFileSync(ubicacionPlantilla, 'utf8') | |
const valorPasadoPorNode = "Soy un valor pasado desde JavaScript"; | |
contenidoHtml = contenidoHtml.replace("{{valor}}", valorPasadoPorNode); | |
pdf.create(contenidoHtml).toFile("salida.pdf", (error) => { | |
if (error) { | |
console.log("Error creando PDF: " + error) | |
} else { | |
console.log("PDF creado correctamente"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment