title: Download as PDF from a JSON post response data in angular 4/5
body: <p><a href="https://i.stack.imgur.com/lIN7y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lIN7y.png" alt="enter image description here"></a></p>
  
  <p>Latest code:::
      convert() {</p>
  
  <pre><code>  const doc = new jsPDF();
    // tslint:disable-next-line:max-line-length
    const col = ['DischargeDate', 'Case Number', 'Patient Name', 'Hospital Name',  'Payor', 'Total Doctor Fee', 'To be Collected'];
    const rows = [];
  
  /* The following array of object as response from the API req  */
  
  const itemNew = this.finalArList;
  
  itemNew.forEach(element =&gt; {
    // tslint:disable-next-line:max-line-length
    const temp = [element.dischargeDate, element.caseNo, element.patientName, element.instName, element.payor, element.totalDrFee, element.drFeeToCollect];
    rows.push(temp);
  
  });
  
    doc.autoTable(col, rows);
    doc.save('Test.pdf');
  }
  </code></pre>
  
  <p>The above is the api url that returns an array of object and in View I am printing those data. Now how to download this list as a pdf format.<a href="https://i.stack.imgur.com/2bFUd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2bFUd.png" alt="enter image description here"></a></p>
  
  <p>json data returned from api call would look something like this. How do I implement download as PDF for this json data.</p>
  
  <p>Okay here is the code I have tried.</p>
  
  <pre><code>public downloadPdf() {
        return this.http
          .get('http://161.202.31.51:8185/sgdocsrv/ar/getARList', {
            responseType: ResponseContentType.Blob
          })
          .map(res =&gt; {
            return {
              filename: 'filename.pdf',
              data: res.blob()
            };
          })
          .subscribe(res =&gt; {
              console.log('start download:', res);
              const url = window.URL.createObjectURL(res.data);
              const a = document.createElement('a');
              document.body.appendChild(a);
              a.setAttribute('style', 'display: none');
              a.href = url;
              a.download = res.filename;
              a.click();
              window.URL.revokeObjectURL(url);
              a.remove(); // remove the element
            }, error =&gt; {
              console.log('download error:', JSON.stringify(error));
            }, () =&gt; {
              console.log('Completed file download.')
            });
      }
  </code></pre>
  
  <p>But it doesnt work . Here the return this.http has a get call, but my api has a post method. I am not sure whats the exact logic to try.</p>