onclick on orderid i want to open that orderid invoice pdf.
as shown in code on click i am sending orderid to api and from there i am calling invoice.getPDFFile(checkorderid).
and in readfile i am pssing path in settings.invoicesHome and file name in invoiceName and i am getting buffer.
[![enter image description here](https://i.stack.imgur.com/E0Erf.png)](https://i.stack.imgur.com/E0Erf.png)

```
.html
<a (click)="openpdf(element.orderId)">{{element.orderId}}</a>

.ts 
openpdf(orderId){
this.httpClient.get(`/adminApi/getPDFFile?orderId=${orderId}`)
  .subscribe(res => {
  console.log(res);
  window.open(res);
  });
}

.js
__api.getPDFFile = function(req , res) {
   var checkorderid = req.query.orderId;
   console.log(checkorderid);
   invoice.getPDFFile(checkorderid)
 .then(function () {
 res.send(data);
   })
   .catch(function (err) {
      console.log();
   });
}

.js
exports.getPDFFile = function(orderId){
   let invoiceName = 'invoice_' + orderId + '.pdf';
   return new Promise((resolve,reject)=>{
      fs.readFile(path.join(settings.invoicesHome, invoiceName),(err, data)=>{
          if (err) {
              reject(err); 
          }
          else{
            resolve(data); 
          }
      });
  })
  .then((data)=>{
      console.log(data); 
  })
  .catch((err)=>{
      throw err; 
  })

```

i want to open pdf file onclick but i am getting buffer how to get pdf.