Hi
On our local and server both the locations when I generate build using yarn run build or npm run build it appends some minified javascript code at the end of the bundle.js fine, it has the following comment:
/*!
I see that you are loading your document via the initialDoc variable inside the Webviewer constructor. Is the URL that is being passed there being malformed?
Could you please comment that line out and try calling instance.UI.loadDocument('your url here')
right after WebViewer instantiates?
We tried applyiong the solution you provided. We commented out the line with initialDoc: “MY_CDN_DOCUMENT_URL”, and added instance.UI.loadDocument(‘your url here’).
We tried adding that line straign below .then(instance => { but it didn’t work, so we tried adding it above instance.UI.enableElements([‘downloadButton’]); but it didn’t work.
On above solution it opened the editor but there is nothing loaded in it.
Thank you for providing the further details. I tried the way you have mentioned. I am still getting the error. This time I selected iframe with id “webviewer-1”, and then inside console I executed the 2 lines given by you. I got an error “Uncaught ReferenceError: instance is not defined”. After that I tried the code you provided earlier mentioned below:
const instance = WebViewer.getInstance();
const { Core, UI } = instance;
UI.loadDocument(‘https://cfdev-cdn.contractorforeman.net/0000_sandbox/50308/notes/large/EstimateABB82.pdf?1737970466055’)
Then it gave me error “Uncaught TypeError: Cannot destructure property ‘Core’ of ‘instance’ as it is null.”.
markup_issue.zip (6.1 MB)
I have attached video inside the zip file for your reference.
Once you select the iframe context, you should have access to the instance variable referring to the WebViewer instance. From there, you should be able to call it’s APIs like instance.UI.loadDocument(‘your url’)
From the video, it looks like the WebViewer instance loads up fine, so the API should work as expected. The issue seems to be coming from your initialDoc variable in the constructor. I recommend breakpointing near that point to see if your url is being passed as correctly to that variable.
@kkim Thank you for providing the details. I tried the way you explained, it loaded the document when I executed the code from the console.
However the code doesn’t work when I update my index.js file and generate build. I passed you the code earlier, could you please check that and let us know your thoughts on what could be wrong in that code?
I would recommend you try rebuilding your application. Otherwise please try checking the network tab again with your application and see if the fetches are going through for the document.
@kkim Thanks for the quick response. I understand that there is no issue with the URL. That’s why I asked you if you could check the code I have provided you earlier, and let me know any possible reason you can find for the issue.
From the previous code provided, it doesn’t look like there is an issue. Could you please try updating to version 8.7 and then rebuild the application?
Please also check the network tab to see if the request for your PDF is also going through.