The ngx-extended-pdf-viewer fail to load the pdf.js viewer when the browser has previously loaded a AMD Loader (for example the loader.js of visual studio code - monaco editor).
Infact, the loadViewer code bases its functioning on this condition:
loadViewer() {
window['ngxZone'] = this.ngZone;
this.ngZone.runOutsideAngular(() => {
if (!window['pdfjs-dist/build/pdf']) { // <----- THIS condition is always true when using AMD Loader so loop infinitly
setTimeout(() => this.loadViewer(), 25);
}
else {
this.needsES5().then((needsES5) => {
const viewerPath = this.getPdfJsPath('viewer', needsES5);
const script = this.createScriptElement(viewerPath);
// script.onload = async () => await this.addFeatures(); // DEBUG CODE!!!
document.getElementsByTagName('head')[0].appendChild(script);
});
}
});
}
But the code in pdf-2.15.350.js define the module is several ways depending on browser capabilities:
The ngx-extended-pdf-viewer fail to load the pdf.js viewer when the browser has previously loaded a AMD Loader (for example the loader.js of visual studio code - monaco editor).
Infact, the
loadViewer
code bases its functioning on this condition:But the code in pdf-2.15.350.js define the module is several ways depending on browser capabilities:
IMHO I think you should base the loadviewer logic on a more generic check.
Version info
Desktop (please complete the following information):
To Reproduce You can use this repo to reproduce the problem https://github.com/gmaggiodev/ngx-extended-pdf-viewer-bug-amdloader.git
In the index.html there is a line to load the loader.js (from microsoft). Comment this line to see the viewer working (without amd loader).