If you have a URL for a document, you can pass it either as a constructor option or to loadDocument to open it.
// Passing a URL into the Web Viewer constructor
WebViewer({
...,
initialDoc: 'https://myserver.com/myfile.pdf',
}, document.getElementById('viewer')).then(instance => {
const { docViewer } = instance;
docViewer.on('documentLoaded', () => {
// perform document operations
});
});
// or
WebViewer(...)
.then(instance => {
instance.loadDocument('https://myserver.com/myfile.pdf', { filename: 'myfile.pdf' });
const { docViewer } = instance;
docViewer.on('documentLoaded', () => {
// perform document operations
});
});
// Passing a URL into the Web Viewer constructor
WebViewer({
...,
initialDoc: 'https://myserver.com/myfile.pdf',
}, document.getElementById('viewer')).then(instance => {
const { documentViewer } = instance.Core;
documentViewer.addEventListener('documentLoaded', () => {
// perform document operations
});
});
// or
WebViewer(...)
.then(instance => {
instance.UI.loadDocument('https://myserver.com/myfile.pdf', { filename: 'myfile.pdf' });
const { documentViewer } = instance.Core;
documentViewer.addEventListener('documentLoaded', () => {
// perform document operations
});
});