Im having some trouble rendering reports using Reports.JS in AWS Lambda. I had previously written lambdas that used Reports.JS without a problem, however now the report does not render all of the pages of my report(Based off the report.renderedPages.count) and appears to output nothing.
I looked a my previous code and found that I was using "render()" to generate the reports instead of "renderAsync()". I now know that that function was made obsolete and will generate an error when I use it. However when I look at the report.renderedPages.count that comes from "render()" it is the full report all pages. Im a bit rusty on my node and I would really appreciate if someone could point me in the right direction. Below is the current code I have generating the report.
Code: Select all
async function generate() {
var reportPath = path.join(__dirname, 'assets/survey.mrt');
var report = new Stimulsoft.Report.StiReport();
report.loadFile(reportPath);
// Export to PDF
let renderReport = await report.renderAsync();
let document = report.exportDocumentAsync((pdfData) => {
console.log("Report rendered. Pages count: ", report.renderedPages.count);
console.log("Rendered report saved into PDF-file.");
var buffer = Buffer.from(pdfData);
sendemail(buffer)
}, Stimulsoft.Report.StiExportFormat.Pdf);
}