Setting initial view state (page number, zoom, scroll position, etc) when opening a PDF doc.

66 views
Skip to first unread message

Tomas Hofmann

unread,
Jun 2, 2016, 5:08:32 PM6/2/16
to PDFTron PDFNet SDK
Q: When I open a PDFDoc in the PDFViewCtrl, I want to set it's initial position, such as what page to show, what zoom level to be in, and what horizontal and vertical scroll position to be in. Calling, for example, PDFViewCtrl.SetCurrentPage(x) right after I call PDFViewCtrl.SetDoc(doc) doesn't always work.

A: The reason this doesn't always work is that our PDFViewCtrl relies on the operating system's management of UI widgets. For example, ScrollViewer can generally not have their position set until they have been measured and loaded by the operating system.
 
In order to make it possible to set an initial view, we have provided a callback or event that can be used to set the view after everything that needs to be ready is loaded. When you set the document, you can set the page presentation mode immediately. But for page number, zoom, and scroll position, you have to use this callback or event.

On Windows Store Apps, listen to the PDFViewCtrl.OnSetDoc event. On Android, provide the PDFViewCtrl with a DocumentLoadListener, and use onDocumentLoaded. On iOS, see PTToolCommon's OnSetDoc function.
Reply all
Reply to author
Forward
0 new messages