Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? No
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? Not sure, but I’m testing on Next.js + React
Is your issue related to annotations? No
Please give a brief summary of your issue:
Issues when attempting to access the WebViewer instance Next.js + React, in order to load a blob.
Please describe your issue and provide steps to reproduce it:
Hello!
I’m attempting to load a blob file via PDFTron WebViewer. To load the WebViewer, I added the following logic:
As you might notice, I added a log, to log the instance value. However, nothing is loaded.
WebViewer is loaded in the client which I find it confusing. This is necessary for me to load the blob file, which it is the next step in the implementation process. However, I cannot even access the instance
I tried running the Next.js sample found here: Apryse Documentation | Documentation. I was not able to your issue where the instance if not found.
I suspect there is another factor that is causing the instance to be null. Do you see any errors in the console or any failed network requests? Perhaps you could try comparing your project to the Next.js sample.
In my example, I tried to use the instance.UI.loadDocument function to load a Blob file.
With that being said, there are a couple things that are happening:
WebViewer is requiring a /public/ui/index.html file to load the iframe.
WebViewer is NOT loading the Blob file I provided via instance.UI.[loadDocument](https://docs.apryse.com/api/web/UI.html#.loadDocument).
Is there any way you could guide me in the right direction? I feel this should be simple, but clearly it is not working unless I load a file stored in the app.
Finally, as a recommendation, it seems there is not an example that gets the WebViewer types. To access the types of the WebViewer, once imported, I had to use the default value returned from the import. Meaning:
I was testing with a console log to ensure the instance was there as I thought it wasn’t getting logged on your end. However, you mentioned it was a loading issue. I think this may not be too unrelated to what I was thinking.
From your code, I wasn’t sure why you left the path option in the constructor as blank and I sort of assumed it was due to some sort of sensitive information. However, you have just provided the error message that might lend to supporting my suspicion. You need to provide that path so that WebViewer can load the UI as well as the workers. It might be failing before you even get to your loadDocument call.
Can you confirm that you have the lib files served and the path is pointing to the correct path?
I also want to mention as well that there is nothing wrong with how you are loading the document, assuming the file is a blob. The type of the file will be inferred by the filename.
However, what it seems to me right now, is that there is something incorrectly set up in your environment right now. Specifically, the WebViewer lib folder that should be statically served is not there.