Whilst using our Viewer object there are several messages that are displayed as popups to inform the user of actions or events to which they should be made aware. However there are cases where you may require that these popups are not displayed, or displayed in a different manner.
In order to allow this we have included an interface that you may implement and use in place of our default message handler. CustomMessageHandler is an interface that, when implemented and passed into the Viewer object, will handle all message popups in a manner that you have specified.
The JPedal jar includes an implementation of the CustomMessageHandler interface called ExampleCustomMessageHandler. This implementation is intended as an example that can you used as a starting point for those wishing to handle the Viewer's popup messages. What the implementation does is to suppress the message popups and instead output the messages to the console.
When writing your own version of the interface, your implementation should take the input and handle it however you desire, then return a given value so the Viewer knows how to proceed. The values for these are detailed in the Javadoc for CustomMessageHandler.
How to add a CustomMessageHandler to the Java PDF viewer
Your own CustomMessageHandler should be added to the viewer before Viewer.setUpViewer() is called. If it is not the Viewer's user interface will use the default option. The CustomMessageHandler can be added with the following code:
PdfDecoderInt pdfDecoder = viewer.getPdfDecoder(); ExampleCustomMessageHandler messageHandler = new ExampleCustomMessageHandler(); pdfDecoder.addExternalHandler(messageHandler, Options.CustomMessageOutput); viewer.setupViewer();