Search code examples
javapdfjavafxfxmlicepdf

ICEPDF hide pagenav , last page and first page


I worked to show pdf in javafx with icepdf libraries.Everything success,but ı don't want to see 'First Page' and 'Last Page' buttons in toolbar.API docs show how to hide page navigator completely.

        propertiesManager.setBoolean("application.toolbar.show.pagenav", false);

I wanna remove only 'First Page' and 'Last Page' buttons.Anyone help please ?


Solution

  • Unfortunately there isn't a configuration option to hide individual navigation buttons. But it's fairly easy to override the SwingViewBuilder method buildPageNavigationToolBar().

    Using the example http://anonsvn.icesoft.org/repo/icepdf/branches/icepdf-6.2.0/icepdf/examples/component/ViewerComponentExample.java you can alter the call:

    SwingViewBuilder factory = new SwingViewBuilder(controller, properties); 
    

    to look like this:

    SwingViewBuilder factory = new SwingViewBuilder(controller, properties){
        @Override
        public JToolBar buildPageNavigationToolBar() {
            JToolBar toolbar = new JToolBar();
            commonToolBarSetup(toolbar, false);
            addToToolBar(toolbar, buildPreviousPageButton());
            addToToolBar(toolbar, buildCurrentPageNumberTextField());
            addToToolBar(toolbar, buildNumberOfPagesLabel());
            addToToolBar(toolbar, buildNextPageButton());
            return toolbar;
        }
    };