westy92/html-pdf-chrome

The CHROME_PATH environment variable must be set to a Chrome/Chromium executable no older than Chrome stable.

dineshkumar14062001 opened this issue · 7 comments

const pdf = require('html-pdf-chrome');

let options = {
printOptions: {
format: "A4",
landscape: false,
marginTop: marginTop,
marginBottom: marginBottom,
marginLeft: marginLeft,
marginRight: marginRight,
displayHeaderFooter: true,
headerTemplate: headerTpl,
footerTemplate: footerTpl,
},
chromeFlags: ['--headless', '--disable-gpu', '--disable-web-security', '--no-sandbox', '--disable-setuid-sandbox']
};

            let pdfBuffer = await pdf.create(htmlContent, options);
            let buffer = pdfBuffer.toBuffer();
            
            ChromePathNotSetError
at new LauncherError (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/utils.js:26:22)
at new ChromePathNotSetError (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/utils.js:33:9)
at Object.linux (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/chrome-finder.js:128:15)
at Function.getFirstInstallation (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/chrome-launcher.js:126:51)
at Launcher.launch (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/chrome-launcher.js:187:43)
at launch (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/node_modules/chrome-launcher/dist/chrome-launcher.js:35:20)
at launchChrome (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/dist/index.js:212:55)
at Object.create (/home/staruser/staracademy-content/node_modules/html-pdf-chrome/dist/index.js:28:24)
at /home/staruser/staracademy-content/routes/services/common-service.js:767:43
at new Promise (<anonymous>)
at Object.generateKatexPdfFile (/home/staruser/staracademy-content/routes/services/common-service.js:723:16)
at /home/staruser/staracademy-content/routes/services/question-answers-service.js:1972:63
at processTicksAndRejections (node:internal/process/task_queues:96:5) {

message: 'The CHROME_PATH environment variable must be set to a Chrome/Chromium executable no older than Chrome stable.',
code: 'ERR_LAUNCHER_PATH_NOT_SET'
}

I have to run in gcp serverless Api
how to solve this error

node version - 16
html-pdf-chrome version - 0.8.4,

What is your chrome(ium) version?

Version 124.0.6367.118 (Official Build) (64-bit)
it is working on my local machine but this error rising in my GCP console.

Is Chrome installed on your GCP instance? If so, what version?

we have used GCP serverless, and did not use any instance.

Html-pdf-chrome requires chrome. You'll likely need a dedicated instance running with a port exposed that your serverless functions can connect to and use.

ok, thank you. I need another question I have printed more than 2000 pages it takes more than 20 minutes, how can I shorten the print pdf?

If you have one instance of Chrome running, monitor its CPU/memory usage. You may need to limit the concurrency of how many simultaneous PDFs you are generating. If the 2000 pages is a single PDF, consider splitting it up into smaller jobs.