I need to be able to change the current page number of a PDF in the PDF Viewer component. How can I do this with Ignition or with some Java?
To directly go forward a page:
target = event.source.parent.getComponent('PDF Viewer') swingController = target.getController() documentController = swingController.getDocumentViewController() swingController.goToDeltaPage(documentController.getDocumentView().getNextPageIncrement())
To choose a specific page, pass a page index to
swingController.showPage(). To get the total number of pages, use
swingController.getPageTree().getNumberOfPages(). Full documentation is available here:
You should be able to suffix a page argument, like so:
Your forum post was very helpful. Additionally I need to implement a button that shows the previous page in the PDF. I suspect that the “getNextPageIncrement()” needs to be replaced. Does anyone know the correct code for the previous page?
There’s a corresponding
I suspected that, but it doesn’t work.
It does the same thing as nextpage
A positive delta indicates moving to later pages, and a negative delta would move to a previous page
The “increment” functions both return a positive integer value.
If you want to go backwards, make it a negative number:
thank you very much. This works perfect. Exactly what I needed.