In GENERIC
builds, dispatch a "webviewerloaded" event (from the webViewerLoad
function) before initializing the viewer
With the removal of the global `PDFJS` object, in PDF.js version `2.0`, the viewer options are no longer as easily accessible as they previously were (and issues have been filed about this). In particular, since the viewer files aren't necessarily loaded *immediately*, this means that `PDFViewerApplication`/`PDFViewerApplicationOptions` aren't necessarily available directly. By dispatching an event once all viewer files are loaded but *before* the viewer initialization has run, setting `AppOptions` during load (in custom implementations of the default viewer) should hopefully become a little bit easier[1]. --- [1] In hindsight, this should probably have been implemented when the global `PDFJS` object was removed...
This commit is contained in:
parent
d9743e462d
commit
0dc995c7e0
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user