Search code examples
javascriptpdfinternet-explorer-9base64

Download base64 pdf with IE9


I have a base64 pdf that I get from external system. I want to be able to download this pdf in IE9 with JavaScript and this is a problem since IE9 doesn't support DATA URI for pdf.

Please help me. Thanks!


Solution

  • You should use Adobe Flash based plugin Downloadify (see the demo) to allow users download file in IE9.

    You may check if the current browser supports dataURI or not using the following js function:

    function CheckDataURISupport(){
    
    var result = true;
    var checkDataURISupportImage = new Image();
    
    checkDataURISupportImage.onload = checkDataURISupportImage.onerror = function(){
        if(this.width != 1 || this.height != 1){
            result = false;
        }
    }
    checkDataURISupportImage.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
    // check if we have datauri support in current browser - end
    
        return result;
    }