From b64c06f68dbad004c4be55fefed77da2f853e101 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Fri, 11 Apr 2014 15:33:34 +0200 Subject: [PATCH] Work-around for filesystem:-URL bug (#4592). Visit https://robwu.nl/pdfjs/filesystem-worker-bug.htm and follow the steps to verify that the extension works as intended with this patch. --- web/viewer.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/web/viewer.js b/web/viewer.js index 7003d9cf0..2355c4015 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -1941,6 +1941,28 @@ function webViewerInitialized() { // return; // } // } +// if (/^filesystem:/.test(file) && !PDFJS.disableWorker) { +// // The security origin of filesystem:-URLs are not preserved when the URL +// // is passed to a Web worker, (http://crbug.com/362061), so we have to +// // create an intermediate blob:-URL as a work-around. +// var resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || +// window.webkitResolveLocalFileSystemURL; +// resolveLocalFileSystemURL(file, function onFileSystemSuccess(fileEntry) { +// fileEntry.file(function(fileObject) { +// var blobUrl = URL.createObjectURL(fileObject); +// PDFView.open(blobUrl, 0, undefined, undefined, { +// length: fileObject.size +// }); +// }); +// }, function onFileSystemError(error) { +// // This should not happen. When it happens, just fall back to the normal +// // way of getting the File's data (via the Web worker). +// console.warn('Cannot resolve file ' + file + ', ' + error.name + ' ' + +// error.message); +// PDFView.open(file, 0); +// }); +// return; +// } // PDFView.open(file, 0); //}); //#endif