small pdf generator performance boosts
parent
476a044e63
commit
78a624f64d
|
|
@ -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(
|
||||||
|
ejsData,
|
||||||
|
pdfCallbackFunction,
|
||||||
|
{
|
||||||
format: "letter",
|
format: "letter",
|
||||||
printBackground: true,
|
printBackground: true,
|
||||||
preferCSSPageSize: 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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue