Jump to specific page in pdf viewer

Hello, I can use the PDF Viewer component in vision to open a .pdf file. It is working fine. Just want to ask if there is posibility to jump to specific page when .pdf document is loaded?
I see there is such posibility in perspective but cannot find it in vision.

Thank you

You can set it via scripting using something like this:

viewer = event.source.parent.getComponent('PDF Viewer')
viewer.getController().showPage(100)
5 Likes

works, thank you.

1 Like

Is it possible to get also actual page number and max page number?
Is somewhere list of all available methods of Vision PDF Viewer? How do You know that there is getController()? I didn't found it in Ignition documentation.
Thanks

No, sorry, this isn't documented. It's part of the underlying PDF library.

You can introspect things by doing something like e.g.

print dir(viewer.getController())

or maybe easier by using one of @pturmel's utility functions.

Try viewer.getController().getCurrentPageNumber() and viewer.getController().getPageTree().getNumberOfPages().

Unfortunately you just have to dig around for these.

1 Like

viewer.getController().getCurrentPageNumber() is returning actual page number, but it is 0 based so first page = 0, second page = 1, ...

viewer.getController().showPage(100) is working in the same way. This example will go to page 101. If ther is no page 101 then it is not doing anything.

For total number of pages I have used viewer.getController().document.numberOfPages. It returns 1 if document has only 1 page.