pdf-creator-node icon indicating copy to clipboard operation
pdf-creator-node copied to clipboard

Working local but not working in server

Open drilonpa opened this issue 2 years ago • 9 comments

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' ] }

drilonpa avatar Nov 04 '22 14:11 drilonpa

Try reinstall the latest version

XXXL3J avatar Dec 12 '22 01:12 XXXL3J

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.

Shaxadhere avatar Dec 29 '22 09:12 Shaxadhere

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...

vignesh291999 avatar Aug 11 '23 06:08 vignesh291999

Та же проблема здесь, я использую 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?

TilliSp avatar Sep 28 '23 09:09 TilliSp

I have fixed this issues

Just try to install chromium in Cloud Servers

drilonpa avatar Sep 28 '23 15:09 drilonpa

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

TilliSp avatar Sep 29 '23 08:09 TilliSp

@TilliSp did you find any solution?

junaidranjha avatar Oct 04 '23 15:10 junaidranjha

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.

gregg-cbs avatar Oct 09 '23 13:10 gregg-cbs

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

drilonpa avatar Oct 09 '23 14:10 drilonpa