Core.dispose() not found

WebViewer Version: 8.0.0

I’m looking into cleaning up resources for the destroy lifecycle of my angular component. I’ve found the webViewerInstance.Core.documentViewer.dispose(); which solves some of the problems I had so that’s great. But I’ve also noticed there’s a webViewerInstance.Core.dispose(); method, with the following description:

Cleans up listeners and data from the WebViewer instance. Should be called when removing the WebViewer instance from the DOM.

That’s sound like something I need! But, despite the function being listed in the docs and in the typings file, at runtime it cannot be found. The doc example tells me to webViewerInstance.Core.dispose(), but doing that results in TypeError: this.instance.Core.dispose is not a function.

And indeed, if I inspect the object it looks like all the properties are there, except for this one method:

Any thoughts on what’s going wrong here? Should I be able to call that method for cleanup or is the webviewer dispose enough?


Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


I looked at the latest nightly and it appears this function got moved to the UI namespace instead.

Yes, it should be fixed in the latest nightly build. Please give it a try. Thanks.


Unfortunately after updating to 8.1.0 this problem came back. I’ve worked on a nightly for a while, accessing dispose through the UI namespace, but in 8.1.0 that’s no longer possible. There is no longer a dispose() on UI and if I try it on Core I get the same thing as in my original post.

I’ve verified that I am indeed using 8.1.0, it’s not an old cached version or something. Immediately after installing it the compiler complained about dispose() not existing on UI. As stated originally, it doesn’t say the same for dispose() on Core but at runtime it’s just not there and it errors.

Any thoughts?


I am working with my colleagues on this. Thanks for your patience.


1 Like


Did you get the instance from window or WebViewer initialization? Thanks


Hey Wanbo,

I got it from WebViewer initialization. So:

this.instance = await WebViewer(...);


I find it somehow under UI namesapce right now, you can access it by instance.UI.dispose() for now I think.


Hi Wanbo,

I’m not sure where you’re looking, but I can’t see it.

It’s not in the docs: PDFTron WebViewer Namespace: UI
And it’s not in typings file either:

It might be there at runtime but if the typings are incomplete I can’t compile my code:

I see it in the source code. Currently there is mismatch between source code and JS doc (which is used to generate the TS typing file). For now, you can just do something like // @ts-ignore or (this.instance.UI as any).dispose().



I suppose that’s better than sticking onto an old nightly, thank you Wanbo.

Could you say anything about the timeframe of when the JS doc+typings file will get fixed?

Np. I will coordinate with my colleague and get it in ASAP, but there’s currently no timeline for this. Thanks.



The fix should be available in tomorrow’s v8.1 nightly build. Thanks.


This still seems to be an issue on 8.2, will continue to use “any” for instance.UI

Hi sr1, just a heads up we ended up removing that line completely. It started throwing errors, “cannot read properties of undefined (reading ‘indexOf’)” iirc.

Considering at that point it wasn’t in any documentation and the messy history of it being (re)moved all the time, we figured we’d just consider it an unsupported method. Support hasn’t explicitly said we need to use it either, and we certainly didn’t want to keep on dealing with it.

We still use the other Dispose call and for as far as we can tell that cleans up enough for a new instance to be created cleanly afterwards. I don’t know if there’s any stuff left in memory but it doesn’t seem to hinder functionality.