mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.8k stars 10.03k forks source link

The PDF doesn't display when called through ajax #8426

Closed aboelmor closed 7 years ago

aboelmor commented 7 years ago

bytetopdf.zip.txt

I am using the base64 trait of pdf.js and have designed a php file (byte_to_pdf --> please remove .txt and unzip the file). When this file is called, it works perfectly. (Please note that I am using IE 9 and IE 11 [it is a must for me])

However, when i call this file through ajax call, it doesn't display. here's my ajax call:

function openPDF_frombyte(byte_string)
{
    $.ajax({
      type: "POST",
      url: "../ALL/byte_to_pdf.php",

      data: { byte_string: byte_string},

         success: function(data){

            var w = window.open();

            var newIframe = w.document.createElement('iframe');        

            newIframe.width = '80%';newIframe.height = '80%';

            w.document.body.appendChild(newIframe);

            newIframe.contentWindow.document.open('text/html');

            newIframe.contentWindow.contents = data;
            newIframe.src = 'javascript:window["contents"]';
            newIframe.window.PDFViewerApplication;
      }
  });
}

Can you please tell me what's the problem. I tried it for testing in chrome and it worked!! but I am obliged to use IE

@yurydelendik

yurydelendik commented 7 years ago

Closing as incomplete -- not enough code is provided to reproduce the issue.