Skip to content
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

TypeError: Cannot read properties of null (reading 'location') #259

Open
Gramli opened this issue Nov 29, 2024 · 1 comment
Open

TypeError: Cannot read properties of null (reading 'location') #259

Gramli opened this issue Nov 29, 2024 · 1 comment

Comments

@Gramli
Copy link

Gramli commented Nov 29, 2024

Hi,

We recently updated to "ng2-pdfjs-viewer" version "18.0.0". After this update, we started encountering an error. We open the PDF viewer in a dialog window, and for the first time, it works correctly. However, when we open the dialog with the PDF viewer again, it starts throwing an exception. Eventually, it displays the PDF properly.

document-viewer.component.ts:18 TypeError: Cannot read properties of null (reading 'location')
    at PdfJsViewerComponent.loadPdf (ng2-pdfjs-viewer.mjs:298:53)
    at PdfJsViewerComponent.refresh (ng2-pdfjs-viewer.mjs:127:14)
    at Object.next (document-viewer.component.ts:16:26)
    at ConsumerObserver.next (Subscriber.js:91:33)
    at SafeSubscriber._next (Subscriber.js:60:26)
    at SafeSubscriber.next (Subscriber.js:31:18)
    at Subject.js:34:30
    at errorContext (errorContext.js:19:9)
    at Subject.next (Subject.js:27:21)

Every time we open dialog with PDF viewer again, number of exception raise up:
image

After we refresh the page with F5, the first opening of the PDF viewer in dialog window is again without errors.

In the previous version, it was OK. Is anyone else encountering this issue too?

Usage:

<div style="width: 100%; height: 100%; min-height: 750px">
  <ng2-pdfjs-viewer #pdfViewer></ng2-pdfjs-viewer>
</div>
  @ViewChild('pdfViewer', { static: true }) pdfViewer: any;

  @Input() set document(value: Observable<Blob>) {
    if (this.pdfViewer && value) {
      value.subscribe((response) => {
        try {
          this.pdfViewer.pdfSrc = response;
          this.pdfViewer.refresh();
        } catch (error) {
          console.error(error);
        }
      });
    }
  }
@aoihikari
Copy link

I am getting the same issue too. If this is not fixed soon, I will have to revert my upgrade and go back to the previous version. Does anyone know if the previous version is compatible with Angular 18?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants