0

I am having a weird problem.

I have a node application which has a .html template and that template is rendered to a pdf using ejs.renderFile and html-pdf library, you can check the following code:

ejs.renderFile("./templates/template.html", data, function (err, html) {
      if (err) {
        throw err;
      }

      var options = {
        format: "Letter",
      };
      // Generate the PDF from the rendered HTML
      console.log("here i am: " + nameOfPDF);
      pdf
        .create(html, options)
        .toFile(path.join(folderPath_, nameOfPDF), function (err, name) {
          if (err) return console.log(err);
          return "success";
        });
    });
  } catch (err) {
    console.log(err);
    return "error:" + err;
  }
  return;
}

Now the pdf generated on my local machine is different than that generated on my hosted machine (ubuntu server), I am talking about the styling.

For reference:

PDF generated on my local: enter image description here PDF generated on my hosted server: enter image description here

While hosting on an the server, I made a bit of change in options which is passed on to pdf.create method, I added childProcess Options to the options object:

      var options = {
        format: "Letter",
        childProcessOptions: {
          env: {
            OPENSSL_CONF: "/dev/null",
          },
        },
      };

Because I was having a openssl_conf error, and this resolved the issue.

I am not able to figure out why two different pdfs (in matter of styling) is generated as the template I used is same.

0 Answers0