0

我努力在带有icepdf库的javafx中显示pdf。一切都成功,但我不想在工具栏中看到“第一页”和“最后一页”按钮。API文档显示了如何完全隐藏页面导航器。

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

我只想删除“第一页”和“最后一页”按钮。有人帮忙吗?

4

2 回答 2

2

不幸的是,没有隐藏单个导航按钮的配置选项。但是重写 SwingViewBuilder 方法 buildPageNavigationToolBar() 相当容易。

使用示例http://anonsvn.icesoft.org/repo/icepdf/branches/icepdf-6.2.0/icepdf/examples/component/ViewerComponentExample.java您可以更改调用:

SwingViewBuilder factory = new SwingViewBuilder(controller, properties); 

看起来像这样:

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;
    }
};
于 2017-06-22T14:04:08.127 回答
0

感谢@pcorless 隐藏打印和保存按钮的使用

SwingViewBuilder factory = new SwingViewBuilder(controller, properties){
public JToolBar buildUtilityToolBar(boolean embeddableComponent, PropertiesManager propertiesManager) {
                JToolBar toolbar = new JToolBar();
                commonToolBarSetup(toolbar, false);
                // if embeddable component, we don't want to create the open dialog, as we
                // have no window manager for this case.
                if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_SEARCH))
                    addToToolBar(toolbar, buildSearchButton());
                if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_UPANE))
                    addToToolBar(toolbar, buildShowHideUtilityPaneButton());

                // Don't bother with this toolbar if we don't have any visible buttons
                if (toolbar.getComponentCount() == 0) {
                    return null;
                }

                return toolbar;
            }
});
于 2021-11-15T21:10:07.333 回答