Did you find this guide helpful?
Some test text!
Web / FAQ / Why does my office file only have 1 page in documentLoaded?
Platform
Documentation
When loading office files, each page is loaded in sequence.
So when the following code is run, the result is that the office file only has 1 page:
documentViewer.addEventListener('documentLoaded', () => {
documentViewer.getCompleteRotation(2); // Throws exception as page 2 is not loaded yet
console.log(documentViewer.getPageCount()); // Returns 1
});
To get the document with all pages loaded, you can await the documentCompletePromise. This promise will resolve when all of the page information is available for the document.
documentViewer.addEventListener('documentLoaded', async () => {
await documentViewer.getDocument().documentCompletePromise();
documentViewer.getCompleteRotation(2); // Works now as all pages are loaded
console.log(documentViewer.getPageCount()); // Returns the correct page count
});
Get the answers you need: Support