I recently started using the excellent ICEpdf library to display PDFs in a Java application. And as invariably happens with most libraries, I wanted to do something that is just not documented anywhere yet. π Or at least anywhere that I can find…
But lets first look at the available documentation:
I am using the Viewer, creating the panel as per the first link above. But I want to configure which buttons are visible on the toolbar at run time, according to user settings persisted in a database. This rules out the option of using the config file route. And hence I needed to find a way to change the configuration programmatically.
So I debugged into the source code, and I found out that there is indeed an easy way. π
[java]SwingController controller = new SwingController();
PropertiesManager propertiesManager = new PropertiesManager(
System.getProperties(), new Properties(),
controller.getMessageBundle());
propertiesManager.setBoolean(
PropertiesManager.PROPERTY_SHOW_UTILITY_SAVE, false);
SwingViewBuilder factory =
new SwingViewBuilder(controller, propertiesManager);
JPanel viewerComponentPanel = factory.buildViewerPanel();[/java]
Hi Hermien, I spent a lot of time trying soulve this feature. Thanks for your work.
In my case I needed change parameter “null” in line 3 to controller.getMessageBundle().
I came across the same thing a few days ago, after writing the original post. That message bundle is used to look up the message that is displayed to the user when first creating a folder in the user’s home directory. So that should indeed preferably not be null.
I updated the code in the post accordingly. Thanks for the feedback! π