How to import global getInstance function

WebViewer Version: 10.11.1

I introduced the WebViewer sdk to a Vue3 project built by Vite with TypeScript enabled. I tried to import getInstance to retrieve existing instance of an element, just like example:

import { getInstance } from '@pdftron/webviewer'

// ...

However, there’s an error:

r TS2614: Module '"@pdftron/webviewer"' has no exported member 'getInstance'. Did you mean to use 'import getInstance from "@pdftron/webviewer"' instead?

2 import { getInstance } from '@pdftron/webviewer'
           ~~~~~~~~~~~


Found 1 error.

I’m sure the types were installed correctly and I can see the types.d.ts under node_modules/@pdftron/webviewer.

What’s the correct way to use this API?

Thank you for posting your question to our forum. We will provide you with an update as soon as possible.

Hello @chenhe,

You cannot getInstance from ‘@pdftron/webviewer’.

Once WebViewer is instantiated, getInstance will be available on the global namespace. Therefore you would be able to use it using window.getInstance().

Kind regards,
Jacob Romano Carlsen
Web Development Support Engineer
Apryse Software Inc.

Thank you for the answer.

So can I assume this reply is wrong: Access webdriver instance from outside of useEffect - #2 by Zhijie_Zhang

Hello @chenhe ,

Thank you for the clarification, I believe I misunderstood.

After further investigation and speaking to the Development team, we found that this is appears to be an issue with the generated types.

We’ve raised the issue as a potential bug and added it to our Defect Backlog for our Product team to review.

We don’t have a timeline for when the issue will be worked on, but we will sure to reach out if the issue has been fixed with a experimental build to try.

In the mean time, our Development team wanted to inform you that the types error can safely be ignored. Thank you for bringing this to our attention.

Kind regards,
Jacob Romano Carlsen
Web Development Support Engineer
Apryse Software Inc.