Class WordFinder

java.lang.Object
com.datalogics.PDFL.WordFinder

public class WordFinder extends Object
A class used to extract words from a document.
  • Constructor Details

    • WordFinder

      public WordFinder(Document doc, WordFinderVersion algVersion, WordFinderConfig wbConfig)
      Create a word finder

      Parameters:
      doc - document in which to find words
      algVersion - algorithm version to use
      wbConfig - configuration for this word finder
  • Method Details

    • delete

      public void delete()
    • enumWords

      public boolean enumWords(int pageNum, WordProc wordProc)
      Extracts words, one at a time, from the specified page or the entire document. It calls a user-supplied procedure once for each word found.

      Only words within or partially within the page's crop box (see Page::CropBox) are enumerated. Words outside the crop box are skipped.

      Word objects passed to wordProc become invalid once the call to EnumWords returns, or if the page number changes between calls to the WordProc.

      Parameters:
      pageNum - The page number from which to extract words. Pass AllPages to sequentially process all pages in the document.
      wordProc - A user-supplied callback to call once for each word found. Enumeration halts if wordProc returns false.
      Returns:
      true if enumeration was successfully completed, false if enumeration was terminated because wordProc returned false.
    • getWordList

      public List<Word> getWordList(int pageNum)
      Finds all words on the specified page and returns a list containing the words. The words are sorted by their x- and y-coordinates on the page.

      Parameters:
      pageNum - the page number for which to get the list of words.
      Returns:
      a list of x, y sorted words on the specified page.
    • getVisibleWordList

      public List<Word> getVisibleWordList(int pageNum)
      Finds all Visible words on the specified page and returns a list containing the words. The words are sorted by their x- and y-coordinates on the page.

      Parameters:
      pageNum - the page number for which to get the list of words.
      Returns:
      a list of x, y sorted words on the specified page.