Displaying Blob PDF in Edge/IE11

北城以北 提交于 2019-11-29 10:00:32

A cross-browser workaround to have an iframe of PDF.js load a blob of a PDF via the iframe URI.

An example of a standard usage case blob URI:

/viewer.html?file=blob:19B579EA-5217-41C6-96E4-5D8DF5A5C70B

File viewer.js:

within function webViewerOpenFileViaURL:

change line from:

if (file && file.lastIndexOf('file:', 0) === 0) {

to:

if (file && file.lastIndexOf('file:', 0) === 0 || file && file.lastIndexOf('blob:', 0) === 0) {

And to further stop the viewer from breaking when the "origin" is behaving in an IE 11/Edge manner:

within function validateFileURL:

change line from:

if (fileOrigin !== viewerOrigin) {

to:

if (fileOrigin != "null" && fileOrigin !== viewerOrigin) {

Now FF, Chrome, IE 11, and Edge all display the PDF in a viewer in the iframe passed via standard blob URI in the URL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!