I am using pdf-creator-node package to create pdf, and somehow its have dependency on html-pdf module. Locally its working file, when its we download on production, its getting above error, "html-pdf": "^3.0.1",", "pdf-creator-node": "^2.3.5","phantomjs-prebuilt": "^2.1.16",i am using above versions.

I tried to set path by using

const options = { format: "A4", orientation: "portrait" , phantomPath : "node_modules/phantomjs-prebuilt/bin/phantomjs"}; 
Still not working , What will happen when i uninstall html-pdf and phantomjs-prebuilt

const template = fs.readFileSync("src/tags.html", "utf8");
    const options = { format: "A4", orientation: "portrait" , phantomPath : phantomPath };
    const document = { html: template, data: { qty: repeatedRows }, path: `./output.pdf`, type: "" };


await pdf.create(document, options);

// Check if the response is still writable before sending the PDF
if (!res.writableEnded) {
  res.setHeader("Content-Type", "application/pdf");
  res.setHeader("Content-Disposition", "attachment; filename=MyDocument.pdf");
  const fspdf = fs.readFileSync(`./output.pdf`);
  res.contentType("application/pdf");
  res.send(fspdf);
} else {
  console.error("EPIPE error occurred. Client closed the connection.");
}
0

There are 0 best solutions below