Performance Issue with Multiple Pages in JS Report
-
We are encountering performance issues when generating reports with multiple pages using JS Report. The process is taking a considerable amount of time to complete.
Below is our current configuration along with the package versions we are using:
Packages and Versions:
@jsreport/jsreport-core: "^4.4.1"
@jsreport/jsreport-jsrender: "^4.0.0"
@jsreport/jsreport-phantom-pdf: "^4.1.0"
jsrender: "^1.0.15"
jsreport: "^4.6.0"Configuration:
const jsreport = require('@jsreport/jsreport-core')({ allowLocalFilesAccess: true, reportTimeout: 300000, reports: { async: true }, logger: { silent: false, error: { transport: 'file', level: 'error', filename: 'logs/error.txt' }, file: { transport: 'file', level: 'info', filename: 'logs/log.txt' }, console: { transport: 'console', level: 'debug', filename: 'logs/console.txt', }, }, templatingEngines: { numberOfWorkers: 4, strategy: 'in-process', templateCache: { max: 100, enabled: true, }, }, }); jsreport.use(require('@jsreport/jsreport-phantom-pdf')()); jsreport.use(require('@jsreport/jsreport-jsrender')()); module.exports = jsreport;
Usage in Controller:
// jsrender jsrender.templates(jsReportData.htmlString); // jsreport jsreport.render({ template: { id: id, shortid: 'ABC', recipe: 'phantom-pdf', engine: 'jsrender', phantom: { format: 'Letter', margin: margin, headerHeight: headerHeight, footerHeight: footerHeight, displayHeaderFooter: displayHeaderFooter, header: header, footer: footer, }, content: htmlContent, }, });
We would appreciate your assistance in improving the performance or any guidance on optimizing our configuration
-
How does the performance differ if you use html recipe? I guess the bottleneck will be the phantomjs html->pdf conversion.
How does chrome-pdf perform for you? The perf is the same?
Please check the perf notes for chrome, the same will apply for phantom
https://jsreport.net/learn/chrome-pdf#performance-optimization