Default code that worked for Chrome and Firefox and not with IE
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$scope.getSingleInvoicePDF = function(invoiceNumberEntity) { var fileName = invoiceNumberEntity + ".pdf"; var pdfDownload = document.createElement("a"); document.body.appendChild(pdfDownload); AngularWebService.getFileWithSuffix("ezbillpdfget",invoiceNumberEntity,"pdf" ).then(function(returnedJSON) { var fileBlob = new Blob([returnedJSON.data], {type: 'application/pdf'}); var fileURL = window.URL.createObjectURL(fileBlob); pdfDownload.href = fileURL; pdfDownload.download = fileName; pdfDownload.click(); }); }; |
Updated code to work on Internet Explorer browser:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$scope.getSingleInvoicePDF = function(invoiceNumberEntity) { var fileName = invoiceNumberEntity + ".pdf"; var pdfDownload = document.createElement("a"); document.body.appendChild(pdfDownload); AngularWebService.getFileWithSuffix("ezbillpdfget",invoiceNumberEntity,"pdf" ).then(function(returnedJSON) { var fileBlob = new Blob([returnedJSON.data], {type: 'application/pdf'}); if (navigator.appVersion.toString().indexOf('.NET') > 0) { // for IE browser window.navigator.msSaveBlob(fileBlob, fileName); } else { // for other browsers var fileURL = window.URL.createObjectURL(fileBlob); pdfDownload.href = fileURL; pdfDownload.download = fileName; pdfDownload.click(); } }); }; |
The same should work for other file types as well.. like “excel”, “csv”.