About the Search Highlight ExampleThe Search example demonstrates how the Search Controller API can be used to search for text in a PDF document. Text that has been found is drawn in a highlighted state to easily identify the results. Search criteria can also be set for case-sensitive and whole word searches. The following code snippet shows how to add search terms tot he searchController and then iterate over any hits. The source-code for this example is located at: A primer on using Maven or Gradle build commands can be found here (Maven) and here (Gradle) DocumentSearchController searchController = controller.getDocumentSearchController(); // add a specified search terms. for (String term : terms) { searchController.addSearchTerm(term, false, false); } // search the pages in the document or a subset Document document = controller.getDocument(); // list of founds words to print out ArrayList<WordText> foundWords; for (int pageIndex = 0; pageIndex < document.getNumberOfPages(); pageIndex++) { foundWords = searchController.searchPage(pageIndex); System.out.println("Page " + pageIndex); if (foundWords != null){ for (WordText wordText : foundWords){ System.out.println(" found hit: " + wordText.toString()); } } } |
Component Search
© Copyright 2017 ICEsoft Technologies Canada Corp.