I am trying to use PDFTron to load several documents and then open them dynamically onClick event. The trouble is I can't access the instance object from outside the return of the WebViewer promise - I need to create dynamic buttons that load a document depending on the button that I click. They are not going to be hardcoded so I can't load in documents from fixed URL's for each button.
Here is the example code from PDFTron. Mine is nearly identical - the only difference is I need the loadDocumentButtons to be dynamic. I don't know a way to do this due to scoping issues; the instance object is trapped within the return of the promise and I don't know how to access it from outside the promise return. Can anyone help with this?
WebViewer({
...
}, viewerElement)
.then(instance => {
loadDocumentButton.on('click', () => {
instance.loadDocument('mysite.com/myDocument.pdf', { documentId: 'id2' });
});
loadAnotherDocumentButton.on('click', () => {
instance.loadDocument('mysite.com/myOtherDocument.pdf', { documentId: 'id2' });
});
});