How to change initialDoc and reload viewer instance with pure Javascript?
Hello, I’m Ron, an automated tech support bot
While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:
Guides:- Integrating PDF.js Express Plus into an existing Blazor project - Integrate PDF.js Express WebViewer
- What is PDF.js Express? - Web Viewer’s iframe
- Best practices for PDF.js Express - Load documents with loadDocument
Hey,
To change the document you do not need to reload the instance (we actually do not recommend reloading the instance at all).
To change documents after the viewer is already loaded, you can use the instance.UI.loadDocument
API:
WebViewer({
path: '/public/express',
}, element).then(instance => {
// ...Somewhere in your code
// Load file via URL
instance.loadDocument('http://yourwebsite.com/document.pdf')
// Load file via Blob
instance.loadDocument(myBlob)
});
More details can be found in our documentation in the “Open a document” section.
Thanks!
Logan