When processing JSReport an empty white screen opens
-
Every time when
jsreport.render({...})
is called, an additional empty screen opens up.This issue appears to be caused by the way the JS Report handles the rendering process, potentially due to incorrect configurations in the chrome-pdf recipe or browser handling of the file.
The file itself generated correctly, but the empty tab should not open during the process.
Please check the following configurations
/**Config*/ 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-handlebars')()); jsreport.use( require('@jsreport/jsreport-chrome-pdf')({ launchOptions: { args: ['--ignore-certificate-errors', '--headless', '--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage'], }, }) ); jsreport.use(require('@jsreport/jsreport-pdf-utils')({ "extensions": { "pdf-utils": { enabled: true, } } }));
module.export = { jsReportRender: async ( _id, headerHeight, footerHeight, displayHeaderFooter, header, footer, htmlContent, headerFooterContent ) => { return new Promise((resolve, reject) => { const templateConfig = { id: id, shortid: 'ABC', recipe: 'chrome-pdf', engine: 'handlebars', chrome: { format: 'Letter', marginRight: '20px', marginLeft: '20px', marginTop: headerHeight, marginBottom: footerHeight, displayHeaderFooter: displayHeaderFooter, headerTemplate: header, footerTemplate: footer, mediaType: 'print', }, content: htmlContent }; // Conditionally add pdfOperations if headerFooterContent is not null if (headerFooterContent) { templateConfig.pdfOperations = [ { type: "merge", template: { content: headerFooterContent, engine: "handlebars", recipe: "chrome-pdf", helpers: ` function getPageNumber (pageIndex) { if (pageIndex == null) { return '' } const pageNumber = pageIndex + 1; return pageNumber; } function getTotalPages (pages) { if (!pages) { return ''; } return pages.length; } ` }, mergeToFront: true, mergeWholeDocument: true, renderForEveryPage: false }, ]; } /** Render the report */ return jsreport.render({ template: templateConfig }).then((out) => { return resolve(out.content); // Ensure the output is properly handled here }) .catch((err) => { console.trace(); console.error(err); reject(err); }); }); } }
We eagerly await your guidance and a solution to address this inconsistency.
Thank you for your assistance.
-
You seems to be sharing server side code which has nothing to do with a new tab opening.
Share the client code you have in the browser that requests jsreport.
-
Yes, you are right I shared server-side code. We have one backend service that receives messages from RabbibtMQ and completes further processing to generate reports based on data and send them to UI.
But if I keep UI down and keep only the backend service running then also a blank tab opens on the server side only.
-
What kind of server is that? A windows server? So a browser suddenly pops up and opens an empty tab?
I don't experience any tab opening on windows.
-
Windows server and node js API.
-
Maybe its a permission issue.
Try the following
https://stackoverflow.com/questions/52701204/windows-10-running-a-puppeteer-script-opens-a-blank-chromium-window
-
We are not using
pappeteer
in our code butjsreport-chorme-pdf
package using it internally. Please check image below.Any configuration that we can set to resolve this issue?
-
Can anyone help me on above issue?
-
Have you checked the link I've shared?