marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.55k stars 544 forks source link

Image not showing when uploaded on vps server #691

Open MohsinUddinAbir opened 1 year ago

MohsinUddinAbir commented 1 year ago

When downloading as pdf on localhost image shows fine but when downloading from VPS Ubuntu server image does not show, instead showing a squire box.

ejs
  .renderFile(path.join(__dirname, "../../utils/invoice.ejs"), {})
  .then((html) => {
     let options = {
        httpHeaders: { "content-type": "application/pdf" },
        orientation: "portrait",
        type: "pdf",
        format: "A4",
     };

     pdf.create(html, options).toStream(function (err, stream) {
        stream.pipe(res);
        return;
     });
  })
})
// invoice.ejs
<div class="col">
  <div class="invoice">
     <img src="https://masterfileservice.com/storage/logo.png" /> 
     <!-- Problem here, image showing on localhost but not showing on VPS Ubuntu server -->
  </div>
</div>