Wait for Document to Load

44 views
Skip to first unread message

Bill Powell

unread,
Oct 13, 2016, 7:54:03 PM10/13/16
to PDFTron WebViewer
I am new to using WebViewer and attempting to integrate it into an existing PHP application.   From PHP I am attempting to Load a document ('myWebViewer.LoadDocument(')  and then go to a certain page.   I do this by calling the javascript to load the document and then SetCurrentPage.

 window.XodViewer.loadDocument("<?php echo $_CONTROL->strFilePath; ?>");
window.XodViewer.setCurrentPageNumber(page);

The document is loading properly but not going to the selected page.   I suspect that the document has not finished loading before the SetCurrentPage is called.   Does LoadDocument return a Promise?   How can I 'wait' until the document is loaded before setting the page number?

Kristian Hein

unread,
Oct 14, 2016, 3:10:08 PM10/14/16
to PDFTron WebViewer
Hello Bill,

You are correct you need to wait until the 'documentLoaded' event is triggered. Here is some example code:

$(document).on('documentLoaded', function() {
  readerControl
.docViewer.setCurrentPage(2);
});

-Kristian
Reply all
Reply to author
Forward
0 new messages