Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
8.0
Detailed description of issue
Can’t change the document in the viewer after openning another document.
Expected behaviour
Hello here, i’m developping an app where customer can see documents they loaded before. i have a issue if i click on a random doc to see it it appears. after closing it and try to access another one the same file appears. The thing is that in my dom my variable is updated but in the viewer no.(Looked at the forum and figured out why. Since it’s a bad pratice i don’t what to reload the viewer several times to keep the performance of my app). Is it possible to update my initial doc every time i need to show up my viewer ? (I’m using Vuejs)
Does your issue happen with every document, or just one?
every document
Link to document
{Provide a link to the document in question if possible}
Code snippet
viewPDF(
{
path: ‘/lib’,
initialDoc: this.currentDoc?.data,
licenseKey:xxxxxxxxxxxxxx
}, document.getElementById(‘viewer’)
).then((instance) => {
this.myInstance = instance
// now you can access APIs through the WebViewer instance
const { Core } = instance
// adding an event listener for when a document is loaded
Core.documentViewer.addEventListener('documentLoaded', () => {
console.log('document loaded')
})
// adding an event listener for when the page number has changed
Core.documentViewer.addEventListener(
'pageNumberUpdated',
(pageNumber) => {
console.log(`Page number is: ${pageNumber}`)
}
)
// adding an event listener for when the page number has changed
Core.documentViewer.addEventListener(
'pagesUpdated',
(changes) => {
console.log(changes)
}
)
})
On click of each document i update my variable and call this code to show document