Nodejs: In ejs renderFile function, linked CSS File is not working in callback HTML

Viewed 69

I am trying to get the HTML from EJS using ejs.renderFile function. Purpose is so that I can made an image of that html and attach to an email. The problem I am facing is that the CSS file I linked in EJS is not working i.e (styling not applied). My main goal is to link the 'bootstrap.min.css' file for styling and use classes of Bootstrap. please see the code.

   function sendBusinessQuotaEmail() {
 const template = `${process.cwd() + "/emailTemplates/businessQuotaEmailTemplate/businessQuotaEmailTemplate.ejs"}`;
const options = [`${process.cwd() + "/emailTemplates/businessQuotaEmailTemplate/businessQuotaEmailTemplate.css"}`];
const templateData = [{abc: 'test'}];
console.log('here sendBusinessQuotaEmail');
ejs.renderFile(template, templateData, (err, html) => {
    if (err) {
        console.log('ejs render file error on line # 7209', err);
        return;
    }
    console.log('html', html);
    nodeHtmlToImage({output: `${process.cwd() + "/tempFiles/download/abc.jpg"}`,html: `${html}`}).then(() => {
        console.log('The image was created successfully!');
    });
});

} enter image description here enter image description here

0 Answers
Related