Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在IE11中使用数据URL打开pdf.js_Javascript_Internet Explorer 10_Pdf.js - Fatal编程技术网

Javascript 在IE11中使用数据URL打开pdf.js

Javascript 在IE11中使用数据URL打开pdf.js,javascript,internet-explorer-10,pdf.js,Javascript,Internet Explorer 10,Pdf.js,我正在尝试使用pdf.js在IE10上的数据URL中显示文档。就是, 它可以与Firefox或Chrome配合使用,但在InternetExplorer10和11中,界面会显示出来,但保持为空,文档也不会加载 我检查过了,compatibility.js包含在渲染器页面(viewer.html)中,因此IE支持应该存在 编辑:实际上这是一个安全问题,因为IE不允许运行这种类型的请求 提前感谢,好的,如果有人遇到同样的问题,我会绕过lib的正常加载路径,并按照async5的建议,将数据直接转换为字

我正在尝试使用pdf.js在IE10上的数据URL中显示文档。就是,

它可以与Firefox或Chrome配合使用,但在InternetExplorer10和11中,界面会显示出来,但保持为空,文档也不会加载

我检查过了,compatibility.js包含在渲染器页面(viewer.html)中,因此IE支持应该存在

编辑:实际上这是一个安全问题,因为IE不允许运行这种类型的请求


提前感谢,

好的,如果有人遇到同样的问题,我会绕过lib的正常加载路径,并按照async5的建议,将数据直接转换为字节数组来解决

也就是说,在viewer.js中,将这些行添加到第6856行下:

  if (file && file.lastIndexOf('data:', 0) === 0) {
      // data: url-scheme. we will load those with direct conversion to byte array

      function convertDataURIToBinary(dataURI) {
          var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
          var base64 = dataURI.substring(base64Index);
          var raw = window.atob(base64);
          var rawLength = raw.length;
          var array = new Uint8Array(new ArrayBuffer(rawLength));

          for(var i = 0; i < rawLength; i++) {
              array[i] = raw.charCodeAt(i);
          }
          return array;
      }

      // PDFViewerApplication.setTitleUsingUrl(file);
      PDFViewerApplication.open(convertDataURIToBinary(file), 0);

      return;
  }
if(file&&file.lastIndexOf('data:',0)==0){
//数据:url方案。我们将加载直接转换为字节数组的方案
函数convertDataURIToBinary(dataURI){
var base64Index=dataURI.indexOf(BASE64\u MARKER)+BASE64\u MARKER.length;
var base64=dataURI.substring(base64Index);
var raw=window.atob(base64);
var rawLength=raw.length;
var数组=新的Uint8Array(新的ArrayBuffer(rawLength));
对于(变量i=0;i

(base64到字节数组的代码是Codetoffel发布的代码)

将数据URL转换为字节数组,并使用PDFViewerApplication打开。打开?请记住,IE也会截断长URL,因此,您的base64编码PDF可能已损坏。在本例中,哪个是PDFViewerApplication?…adobe reader?不,它是PDF.js内部的一个类。是否有任何其他解决方法可以使用PDF.js使其在IE11中工作?…我的意思是,对于IE中的支持来说,这太多开销了:(您确实可以在外部应用程序、Adobe或Window的Reader应用程序中打开PDF。