Product:
PDF TRON
Product Version: 8.12.0
Please give a brief summary of your issue:
I want to scroll to a specific page number once the document is loaded
Please describe your issue and provide steps to reproduce it:
Below code works fine. I loaded a static file and jump to page 5
useEffect(() => {
(async function loadWebViewer() {
const WebViewer = (await import(‘@pdftron/webviewer’)).default;
if (viewer.current) {
WebViewer(
{
path: ‘/webviewer’,
autoExpandOutlines: false,
disabledElements: disabledUIElements,
},
viewer.current
).then(instance => {
inst.current = instance;
const { documentViewer } = instance.Core;
instance.UI.loadDocument('/files/pdftron_about.pdf', { documentId: 'id2' });
documentViewer?.addEventListener('documentLoaded', async () => {
documentViewer?.setCurrentPage(5, true); // Goes to page 5 of the document
});
});
}
})();
}, []);
But when I get the documents from an API call, the document scroll to page 5 it but jumps back to the first page. Below is the sample code
useEffect(() => {
(async function loadWebViewer() {
const WebViewer = (await import(‘@pdftron/webviewer’)).default;
if (viewer.current) {
WebViewer(
{
path: ‘/webviewer’,
autoExpandOutlines: false,
disabledElements: disabledUIElements,
},
viewer.current
).then(instance => {
inst.current = instance;
const { enableFeatures, disableFeatures, Feature } = instance.UI;
const { documentViewer } = instance.Core;
disableFeatures([Feature.Annotations]);
instance.UI.setHeaderItems(header => {
addAnnotationToHeaderPanel(header, enableFeatures, disableFeatures, Feature);
});
instance.UI.loadDocument('/files/pdftron_about.pdf', { documentId: 'id2' });
getDocument(
licenseResponse => {
if (isSuccess(documentURL)) {
const uri = getContentURI(`${documentURL`);
instance.UI.loadDocument(uri, { documentId: 'id2' });
}
},
docId,
'pdf'
);
documentViewer?.addEventListener('documentLoaded', async () => {
documentViewer?.setCurrentPage(5, true); // Goes to page 5 of the document
});
});
}
})();
}, []);
Please let me know if I am missing something
Please provide a link to a minimal sample where the issue is reproducible: