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

Working local but not working in server #100

Open
drilonpa opened this issue Nov 4, 2022 · 9 comments
Open

Working local but not working in server #100

drilonpa opened this issue Nov 4, 2022 · 9 comments

Comments

@drilonpa
Copy link

drilonpa commented Nov 4, 2022

Error: spawn /home/node/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19) at onErrorNT (node:internal/child_process:485:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /home/node/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs', path: '/home/node/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs', spawnargs: [ '--local-url-access=false', '/home/node/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js' ] }

@XXXL3J
Copy link

XXXL3J commented Dec 12, 2022

Try reinstall the latest version

@Shaxadhere
Copy link

Maybe this is because it uses headless chrome and your server does not have chrome installed even if it's installed maybe it cannot find the path to chrome on the server. I had a similar issue using puppeteer and I fixed it by installing chrome on the server and giving it the path to chrome.

@vignesh291999
Copy link

Same issue here also I am using pdf-creator-node

const document = {
html: html,
data: data,
path: '',
type: 'buffer',
};

  const created = await pdf.create(document, options);
  res.setHeader('Content-disposition', `attachment; filename="${downloadFile}"`);
  res.setHeader('Content-Type', 'application/pdf');
  res.end(created);
}

locally its working fine pdf is generating in download folder but when hosted in Azure its not working as expected...

@TilliSp
Copy link

TilliSp commented Sep 28, 2023

Та же проблема здесь, я использую pdf-creator-node

const document = { html: html, data: data, path: '', type: 'buffer', };

  const created = await pdf.create(document, options);
  res.setHeader('Content-disposition', `attachment; filename="${downloadFile}"`);
  res.setHeader('Content-Type', 'application/pdf');
  res.end(created);
}

локально его работающий PDF-файл генерируется в папке загрузки, но при размещении в Azure он не работает должным образом...

@vignesh291999 were you able to solve the problem?

@drilonpa
Copy link
Author

I have fixed this issues

Just try to install chromium in Cloud Servers

@TilliSp
Copy link

TilliSp commented Sep 29, 2023

@drilonpa
What do you mean? Chrome driver or ...what? Sorry, I`m new to this (:

@junaidranjha
Copy link

@TilliSp did you find any solution?

@gregg-cbs
Copy link

gregg-cbs commented Oct 9, 2023

Ahh the reason this does not work when being deployed to any platform is that this package is using 'html-pdf' which is a development only library - all its dependencies are devDependencies.

So when you deploy to production none of its dependencies get installed.

This is really poor decision making from @hajareshyam who used that package. It actually seems that this author has never used this package in production.

Furthermore html-pdf package is deprecated along with all its dependencies. I would imagine this package to be slow and resource intensive because it is using phantomjs which is a headless browser.

The author should do us a favour and remove this package from github and npm because this has become a massive waste of time.

@drilonpa
Copy link
Author

drilonpa commented Oct 9, 2023

@TilliSp
Based on your OS system in cloud server you need to install
https://www.chromium.org/getting-involved/download-chromium/

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

7 participants