diff --git a/web/viewer.js b/web/viewer.js index 8885162b2..2254731fc 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -203,6 +203,16 @@ function webViewerLoad() { window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication; window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions; + + if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) { + // Give custom implementations of the default viewer a simpler way to + // set various `AppOptions`, by dispatching an event once all viewer + // files are loaded but *before* the viewer initialization has run. + const event = document.createEvent('CustomEvent'); + event.initCustomEvent('webviewerloaded', true, true, {}); + document.dispatchEvent(event); + } + pdfjsWebApp.PDFViewerApplication.run(config); } }