diff --git a/web/viewer.js b/web/viewer.js index cf0390472..9ecfc0d19 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -913,7 +913,7 @@ var PDFView = { DocumentProperties.resolveDataAvailable(); - pdfDocument.getDownloadInfo().then(function() { + var downloadedPromise = pdfDocument.getDownloadInfo().then(function() { self.downloadComplete = true; PDFView.loadingBar.hide(); var outerContainer = document.getElementById('outerContainer'); @@ -988,9 +988,11 @@ var PDFView = { } }); - var event = document.createEvent('CustomEvent'); - event.initCustomEvent('documentload', true, true, {}); - window.dispatchEvent(event); + downloadedPromise.then(function () { + var event = document.createEvent('CustomEvent'); + event.initCustomEvent('documentload', true, true, {}); + window.dispatchEvent(event); + }); PDFView.loadingBar.setWidth(container);