com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class NoteTextExtractor

  • All Implemented Interfaces:
    IHighlightExtractor, IPageTextExtractor, IRegexSearchable, ISearchable, AutoCloseable


    public final class NoteTextExtractor
    extends TextExtractor
    implements ISearchable, IHighlightExtractor, IRegexSearchable, IPageTextExtractor

    Provides the text extractor for OneNote documents.

    Extracting a text from OneNote section:

     // Create a text extractor for OneNote sections
     NoteTextExtractor extractor = new NoteTextExtractor(stream);
     // Extract a text
     System.out.println(extractor.extractAll());
      

    Extracting text by pages:

     // Create a text extractor for OneNote sections
     NoteTextExtractor extractor = new NoteTextExtractor(stream);
     // Iterate pages
     for (int pageIndex = 0; pageIndex < extractor.getPageCount(); pageIndex++) {
         // Extract a text from the page which index is pageIndex
         System.out.println(extractor.extractPage(pageIndex));
     }
      
    • Constructor Detail

      • NoteTextExtractor

        public NoteTextExtractor(String fileName)

        Initializes a new instance of the NoteTextExtractor class.

        Parameters:
        fileName - The path to the file.
      • NoteTextExtractor

        public NoteTextExtractor(String fileName,
                         LoadOptions loadOptions)

        Initializes a new instance of the NoteTextExtractor class.

        Parameters:
        fileName - The path to the file.
        loadOptions - The options of loading the file.
      • NoteTextExtractor

        public NoteTextExtractor(InputStream stream)

        Initializes a new instance of the NoteTextExtractor class.

        Parameters:
        stream - The stream of the document.
      • NoteTextExtractor

        public NoteTextExtractor(InputStream stream,
                         LoadOptions loadOptions)

        Initializes a new instance of the NoteTextExtractor class.

        Parameters:
        stream - The stream of the document.
        loadOptions - The options of loading the file.
    • Method Detail

      • getPageCount

        public int getPageCount()

        Gets a total count of the pages.

        Specified by:
        getPageCount in interface IPageTextExtractor
        Returns:
        A total count of the pages.
      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        keywords - A collection of words to search.
      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  ISearchEngine searchEngine,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        searchEngine - An instance of the search engine.
        keywords - A collection of words to search.
      • extractHighlights

        public List<String> extractHighlights(HighlightOptions... highlightOptions)

        Extracts highlights.

        Specified by:
        extractHighlights in interface IHighlightExtractor
        Parameters:
        highlightOptions - A collection of HighlightOptions.
        Returns:
        A collection of strings that represent highlights. If no highlight is found, a collection is empty.
      • reset

        public void reset()

        Resets the current document.


        Resets the cursor's position. ExtractLine method will return the first line of the document.

        Overrides:
        reset in class TextExtractor
      • extractPage

        public String extractPage(int pageIndex)

        Reads all characters from the page with pageIndex and returns the data as a string.

        Specified by:
        extractPage in interface IPageTextExtractor
        Parameters:
        pageIndex - The index of the page.
        Returns:
        A string that contains all characters from the page, or null if all characters have been read.
      • dispose

        protected void dispose(boolean disposing)

        Releases the unmanaged resources used by the extractor.

        Overrides:
        dispose in class TextExtractor
        Parameters:
        disposing - A boolean true if invoked from Dispose; otherwise, false.
      • prepareLine

        protected String prepareLine()

        Returns a line of the text.

        Specified by:
        prepareLine in class TextExtractor
        Returns:
        A string that represents a line of the text, or null if all characters have been read.