showing results for - "angular download blob pdf"
Khadija
27 Apr 2016
1getPDF(){
2      this.apiService.getPDF(this.invoiceId)
3      .subscribe(
4        (data: Blob) => {
5          var file = new Blob([data], { type: 'application/pdf' })
6          var fileURL = URL.createObjectURL(file);
7
8// if you want to open PDF in new tab
9          window.open(fileURL); 
10          var a         = document.createElement('a');
11          a.href        = fileURL; 
12          a.target      = '_blank';
13          a.download    = 'bill.pdf';
14          document.body.appendChild(a);
15          a.click();
16        },
17        (error) => {
18          console.log('getPDF error: ',error);
19        }
20      );
21    }
22