Open drilonpa opened 1 year ago
Try reinstall the latest version
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.
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...
Та же проблема здесь, я использую 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?
I have fixed this issues
Just try to install chromium in Cloud Servers
@drilonpa What do you mean? Chrome driver or ...what? Sorry, I`m new to this (:
@TilliSp did you find any solution?
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.
@TilliSp Based on your OS system in cloud server you need to install https://www.chromium.org/getting-involved/download-chromium/
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' ] }