-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDFScriptLoaderService fails to properly load the pdfjs viewer after destroyed. #2510
Comments
Tricky indeed. To be honest, I'm a clueless. |
Esiest fix I can up with is to cachebust the viewer mjs file. Two lines changed:
and in
Not the best solutions... since it also bypasses the browser cache. |
Guessing the better fix is to wrap these lines in a global function that gets called onload. https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/assets/viewer-4.5.713.mjs#L38804C1-L38812C31 |
DOESN'T WORK
|
OK.. Here is the best I got: In
In
|
Could bypass the I can do a PR if you are happy with having |
I think we need a solution that does not pollute the global namespace. The best solution would be to wrap the viewer file in an Angular component. Unfortunately, I haven't managed to do that yet. In the long run, I'd like to be able to have multiple independent instances of the viewer simultaneously. It seems many developers need this feature, and https://pdfviewer.net/extended-pdf-viewer/side-by-side uses a very clumsy work-around. |
@Hypercubed What's the current state of the art? Do you expect me to do something, or do you want to send a pull request? Oh, and I wish you a Happy New Year! |
Happy new year to you! I haven't look at this in a little while. I belive I had a not so great solution... I'll need to look again. |
Here is a tricky one.... I noticed that when running >v21, component tests started breaking. After quick a bit of investigation I'm pretty sure I've narrowed down the issue to the changes introduced in 21.0.0-alpha.0. Here is the breakdown:
21.0.0-alpha.0 introduces
PDFScriptLoaderService
which loads the pdfjs viewer inside theloadViewer
method. TheloadViewer
method relies on thengxViewerFileHasBeenLoaded
event being triggered when loading the viewermjs
file. This works fine on initial load since themjs
file includes the event trigger. However, in unit/component testing the Angular app is destroyed and thePDFScriptLoaderService#destroy
method is called to cleanup. The Angular app is then "rebooted" in the same window. But since the viewer is loaded as a module, it is not executed again (ES modules are loaded once and reused). ThengxViewerFileHasBeenLoaded
event is never triggered and therefore the pdfjs is never initailzed.Seams like we need a different way to trigger the listener inside
loadViewer
that doesn't rely on side effects inside the module.I've only seen this in testing; since a app usually has the same lifecycle as the document/window.
The text was updated successfully, but these errors were encountered: