PDF Viewer Page Numbers Accessible?

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?

2 Likes

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:
http://res.icesoft.org/docs/icepdf/v4_3_2/viewer/javadocs/org/icepdf/ri/common/SwingController.html

7 Likes

You should be able to suffix a page argument, like so:
http://www.pdf995.com/samples/pdf.pdf#page=5

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 getPreviousPageIncrement function.

I suspected that, but it doesn’t work.
It does the same thing as nextpage

http://res.icesoft.org/docs/icepdf/v4_3_2/viewer/javadocs/org/icepdf/ri/common/SwingController.html#goToDeltaPage(int)

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:
swingController.goToDeltaPage(-documentController.getDocumentView().getPreviousPageIncrement())

1 Like

thank you very much. This works perfect. Exactly what I needed.