small pdf generator performance boosts

deepsource-autofix-76c6eb20
Dan Gowans 2022-10-11 15:42:56 -04:00
parent 476a044e63
commit 78a624f64d
1 changed files with 21 additions and 10 deletions

View File

@ -38,22 +38,33 @@ export const handler: RequestHandler = async (request, response, next) => {
response.send(pdf); response.send(pdf);
}; };
reportData.configFunctions = configFunctions; const ejsCallbackFunction = async (ejsError: Error, ejsData: string) => {
reportData.dateTimeFunctions = dateTimeFunctions;
await ejs.renderFile(reportPath, reportData, {}, async (ejsError, ejsData) => {
if (ejsError) { if (ejsError) {
return next(ejsError); return next(ejsError);
} }
await convertHTMLToPDF(ejsData, pdfCallbackFunction, { await convertHTMLToPDF(
format: "letter", ejsData,
printBackground: true, pdfCallbackFunction,
preferCSSPageSize: true {
}); format: "letter",
printBackground: true,
preferCSSPageSize: true
},
undefined,
{
cacheBrowser: true,
remoteContent: false
}
);
return; return;
}); };
reportData.configFunctions = configFunctions;
reportData.dateTimeFunctions = dateTimeFunctions;
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
}; };
export default handler; export default handler;