• Skip to content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Content
  • Java
  • Sightly
  • AngularJS
  • Web services
  • More
    • Testing
    • Adobe Marketing Cloud
      • Adobe Analytics
      • Adobe Campaigns
      • Adobe Target
    • Replication
    • Forms
    • Files
    • 3rd Party
    • Troubleshooting
    • Installation and Configuration
    • References

Practical AEM

By Developers To Developers

  • Content
  • Java
  • Sightly
  • AngularJS
  • Web services
  • More
    • Testing
    • Adobe Marketing Cloud
      • Adobe Analytics
      • Adobe Campaigns
      • Adobe Target
    • Replication
    • Forms
    • Files
    • 3rd Party
    • Troubleshooting
    • Installation and Configuration
    • References

Issues with download files in IE using Angular and Fix

November 20, 2015 By ksurendra

Default code that worked for Chrome and Firefox and not with IE

Snipper from Angular Controller - workes in Chrome and Firefox
JavaScript
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:

Snipper from Angular Controller - Fix for IE
JavaScript
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”.

Filed Under: AngularJS, Files Tagged With: angularjs, file-download

Primary Sidebar

  • Facebook
  • Google+
  • Instagram
  • LinkedIn
  • Pinterest
  • Twitter

Angular JS

Issues with download files in IE using Angular and Fix

November 20, 2015 By ksurendra

AngularJS Setup in AEM

November 11, 2015 By ksurendra

More Topics

  • 3rd Party
  • AngularJS
  • Assets
  • Content
  • Dispatcher
  • Files
  • Forms
  • Installation and Configuration
  • Java
  • References
  • Replication
  • Reports
  • Sightly
  • Sling
  • Testing
  • Troubleshooting
  • Uncategorized
  • Web services

Footer

About Us

This is an example of a text widget which can be used to describe a particular service. You can also use other widgets in this location.

Examples of widgets that can be placed here in the footer are a calendar, latest tweets, recent comments, recent posts, search form, tag cloud or more.

Sample Link.

Recent Posts

  • Configuring AEM as a Service on CentOS 7
  • How to set httpOnly and Secure flags on login-token
  • Thumbnails and Renditions for EPS and AI files in AEM – Using ImageMagick and GhostScript
  • Integrating Webtrends with AEM
  • Integrate AEM with Tealium
  • AEM 6.2 Out-of-the-box Asset Reports
  • AEM 6.2 Out-of-the-box Reports

Search

Tags

activate aem aem 6.2 analytics angularjs asset reports books brackets content crx disk space dispatcher dropdown-lists eclipse ffmpeg file-download git google-maps imagemagick junit miscadmin mockito oauth ootb page activity report recaptcha references reports rest reverse proxy sightly sling-servlet submit-action tag management tealium testing tools vault video video-renditions videos vlt wcmusepojo web services webtrends

Copyright © 2019 · Magazine Pro on Genesis Framework · WordPress · Log in