I am new to node.js and jsreport, but what I'm trying to do is create a pdf file in memory using node.js and then save it to disk. I need this to stand, as it will work as an AWS Lambda function.
var fs = require('fs'); require("jsreport").render("<h1>Hi there!</h1>").then(function(out) { //pipe pdf with "Hi there!" fs.writeFile('C:\\helloworld.pdf', out, function (err) { if (err) return console.log(err); console.log('Hello World > helloworld.txt'); }); fs.close(); console.log("The End"); });
Although this works, the pdf output does not open in Adobe Reader, so I assume that the output of the file is not a valid PDF.
this requires npm install jsreport
source share