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

Open pdf.js with a data URL in IE11

我正在尝试使用 pdf.js 在 IE10 上显示数据 URL 中的文档。即something like this.

它适用于 Firefox 或 Chrome,但在 Internet Explorer 10 和 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;
  }

(base64转字节数组的代码是Codetoffel贴出来的here