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
ERROR Error: Uncaught (in promise): UnknownErrorException: Window is not defined while displaying pdf using base64 string from server #1059
Comments
That may be bad news because it might mean I have to remove a popular feature. So let's examine your case thoroughly first. Which version of ngx-pdf-extended-pdf-viewer are you using? And are you using the default branch or the "bleeding edge" branch? |
I am using following version of ngx-extended-pdf-viewer I am on default branch. Which feature is related with it and what is causing this issue? Some more points that I observed -
|
It's the feature we've decided to build in #804: allow users to filter log messages. The idea was to replace every console.log call by a custom call. However, the service worker thread doesn't have a Window object, and even trying to check if the Window object exists causes the service worker to crash. I don't understand this. That's not the usual behavior of JavaScript. I'm running out of ideas. There must be a way to detect whether the code is running in a server worker or in a regular UI thread, but I haven't found out yet how to do this! function info(msg) {
if (verbosity >= VerbosityLevel.INFOS) {
if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {
console.log(`Info: ${msg}`);
} else if (Window && Window['ngxConsole']) { <<<<<<< Service worker crashes here!
Window['ngxConsole'].log(`Info: ${msg}`);
} else {
console.log(`Info: ${msg}`);
}
}
} |
@chetan592 Please update to version 11.0.0-alpha.10. If this fixes your bug, please tell me. If it doesn't, please tell me, too. I've tried to implement a bugfix in version 11.0.0-alpha.6, and I'd like to know for sure if it fixes the bug or not. |
@stephanrauh Thanks for support you are providing to community. I updated it to the 11.0.0-alpha.10. Now PDFs that were having issues are loaded and shown successfully. But warning of window not defined is there in console.Also sometimes it shows couple of warning on console including that of window undefined reference error. Anything to worry about those warnings? Attached screenshots for your reference. |
Hooray! That's good news. But you're right, some of these warnings are exceptions that must be fixed. They prevent displaying the digital signature of the file. As for the other messages:
|
…dded missing translations for a few languages; update the build chain to Angular 13; stop versioning the generated files on GitHub (with the exception of the non-minified ESNext files)
fixed with version 11.0.0-alpha.12. |
I am using ngx-extended-pdf-viewer to show pdf using base64 strings that I receive from server.
I am not sure but I think it was not there when I was trying it for images from asset folder
For some pdf I get this issue where pdf is not visible and throws error, which is in console .
This issue may be because of base library but little direction towards solving it would be very helpful for me.
Adding screenshot for ref
The text was updated successfully, but these errors were encountered: