I am using this html-pdf-node library to convert html to pdf file in nodejs side. After converting it returns the pdf buffer, that i use to send to mail.
Here is the code
const file = { content: attachementPdfContentString };
return htmlToPdf.generatePdf(file, options).then(pdfBuffer => {
try {
return this.sendMail({
to: hotelEmail,
subject: "Dashback Invoice",
body: `Hi `,
attachments: [
{
filename: 'invoice.pdf',
content: Buffer.from(pdfBuffer, 'utf-8')
}
]
});
} catch (err) {
console.error("Unable to send mail for hotel invitation", JSON.stringify(invoice));
throw err;
}
this works on local system, pdf is getting sent to mail using nodemailer. But when I run the same code on heroku dyno, it shows
2022-11-29T15:43:13.506732+00:00 app[web.1]: Error: Failed to launch the browser process!
2022-11-29T15:43:13.506734+00:00 app[web.1]: /app/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
2022-11-29T15:43:13.506734+00:00 app[web.1]:
2022-11-29T15:43:13.506734+00:00 app[web.1]:
2022-11-29T15:43:13.506735+00:00 app[web.1]: TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
2022-11-29T15:43:13.506735+00:00 app[web.1]:
2022-11-29T15:43:13.506735+00:00 app[web.1]: at onClose (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
2022-11-29T15:43:13.506736+00:00 app[web.1]: at Interface.<anonymous> (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
2022-11-29T15:43:13.506736+00:00 app[web.1]: at Interface.emit (node:events:525:35)
2022-11-29T15:43:13.506737+00:00 app[web.1]: at Interface.close (node:internal/readline/interface:536:10)
2022-11-29T15:43:13.506738+00:00 app[web.1]: at Socket.onend (node:internal/readline/interface:262:10)
2022-11-29T15:43:13.506738+00:00 app[web.1]: at Socket.emit (node:events:525:35)
2022-11-29T15:43:13.506738+00:00 app[web.1]: at endReadableNT (node:internal/streams/readable:1359:12)
2022-11-29T15:43:13.506739+00:00 app[web.1]: at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
How can i solve this, or any other library or way?