show a pdf in 64 bit in iexplorer

267 Views Asked by At

I need to show a PDF file with data, this data is data:application/pdf;base64, @Session["Pdf"] .

So the process works in my machine I open the PDF and automatically adn the PDF appears with a data in GOOGLE CHROME.

The problem is when I make this process in a web environment or IE , the HTML page does not show anything.

1 st tentative

<body> <object data="data:application/pdf;base64, @Session["Pdf"]" type="application/pdf" style="width: 100%; height: 100%;" frameborder="0" scrolling="no"> <p>It appears you don't have Adobe Reader or PDF support in this web browser. </p> <embed src="data:application/pdf;base64, @Session["Pdf"]" type="application/pdf" /> </object> </body>

2 st tentative

<div class="modal-body"> <iframe src="data:application/pdf;base64, @Session["Pdf"]" style="width: 100%; height: 100%;" frameborder="0" scrolling="no"> @*<embed src="@Session["Pdf"]"></embed>*@ </div>

3 st

 <script type="text/javascript">

 var data= "data:application/pdf;base64,@Session["Pdf"]" ;

if (data == "" || data == undefined) {
    alert("Falied to open PDF.");
} else { 
    //For IE using atob convert base64 encoded data to byte array
    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        var byteCharacters = atob(data);
        var byteNumbers = new Array(byteCharacters.length);
        for (var i = 0; i < byteCharacters.length; i++) {
            byteNumbers[i] = byteCharacters.charCodeAt(i);
        }
        var byteArray = new Uint8Array(byteNumbers);
        var blob = new Blob([byteArray], {
            type: 'application/pdf'
        });
        window.navigator.msSaveOrOpenBlob(blob, fileName);
    } else { 
        // Directly use base 64 encoded data for rest browsers (not IE)
        var base64EncodedPDF = data;
        var dataURI = "data:application/pdf;base64," + base64EncodedPDF1;
        window.open(dataURI, '_blank');
    }
  }
  </script>
0

There are 0 best solutions below