Java PDF Menu Bar Search
This article explains how to activate the menu bar pdf search and how the functionality works.
Activating Menu Bar Search
The menu bar search can be activated by changing a setting in the properties file. The setting is <searchWindowType value="2"/> with the value of 2 being the menu bar search.
This can be achieved by either manualy altering the value within the xml file or via the simpleviewer preferences window
Menu Bar Search Gui Components
The above picture shows the viewer with the search menu bar active.
The menu bar search has three gui components, a text field, a previous result button and a next result button. The next and previous buttons only become visible once a search as been performed.
To perform a search you simply type what you wish to search for into the text field and press enter. As soon as a result is found the previous and next buttons become active and you can navigate the through the results.
How The Menu Bar Search Works
When a search is perfomed jPedal will perform a search on the given page and then continue to all the following pages untill a result is found then the search ends. Once a result is found the search will finish at the end of that page. If the search reaches the final page it will continue from the first page until it reaches the page where the search began.
Once a result is found the navigation buttons become active. The navigation buttons will allow you to navigate the results on the current page. If you get to the end or begining of the results on this page and try to continue then the search is started again continuing through the pages in the given direction (backwards or forward) looking for another valid result.
Using This Functionality Programatically
All the functionality that allows the search to work in this manner can be accessed programatically within your own application. All the functionality can be accessed via either Commands.executeCommand(int commandID, Object[] args) or Simpleviewer.executeCommand(int commandID, Object[] args) using various int values and arguements to performed different commands. You can find more information about the find, next result and previous result commands here.
To ensure that the functionality works as described above when accessed programmatically please ensure that the menu bar search is activated by changing the setting <searchWindowType value="2"/> so that it has the value of 2.
Links to related articles
FindTextInRectangle example will find locations of word on PDF page.
Access PDF Search functionality through SimpleViewer
Return to main PDF support section
Click here for the main PDF support area with lots of java examples, PDF tutorials and useful information to get the most out of the JPedal PDF library




