Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dineshkumar14062001 opened this issue May 2, 2024 · 7 comments

Comments

@dineshkumar14062001
Copy link

dineshkumar14062001 commented May 2, 2024

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,

@westy92
Copy link
Owner

westy92 commented May 13, 2024

What is your chrome(ium) version?

@dineshkumar14062001
Copy link
Author

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

@westy92
Copy link
Owner

westy92 commented May 14, 2024

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

@dineshkumar14062001
Copy link
Author

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

@westy92
Copy link
Owner

westy92 commented May 14, 2024

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.

@dineshkumar14062001
Copy link
Author

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?

@westy92
Copy link
Owner

westy92 commented May 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants