Error processing SSI file
LEADTOOLS Leadtools.Documents.UI (Leadtools.Documents.UI assembly)

Show in webframe

Find Method






Data that contains the text to find.
true to perform a "find" operation, otherwise, continues searching for either next or previous text.
true to perform a "find next" operation; otherwise, false to perform a "find previous" operation.
Performs a "find", "find next" or "find previous" search operation on the text of the document.
Syntax
'Declaration
 
Public Function Find( _
   ByVal findText As DocumentViewerFindText, _
   ByVal isFirst As Boolean, _
   ByVal findNext As Boolean _
) As IList(Of DocumentViewerTextItem)
'Usage
 
Dim instance As DocumentViewerText
Dim findText As DocumentViewerFindText
Dim isFirst As Boolean
Dim findNext As Boolean
Dim value As IList(Of DocumentViewerTextItem)
 
value = instance.Find(findText, isFirst, findNext)

Parameters

findText
Data that contains the text to find.
isFirst
true to perform a "find" operation, otherwise, continues searching for either next or previous text.
findNext
true to perform a "find next" operation; otherwise, false to perform a "find previous" operation.

Return Value

A list of the text items found, or null if no next was found with this operation.
Remarks

Find and LastFindText are used together to perform "find", "find next" and "find previous" text search operations.

Typical applications that perform text search contain a menu item for "Find", "Find Next" and "Find Previous". The following explains how to use Find and LastFindText to perform these operations.

The LEADTOOLS Document Viewer demo uses the above to perform text search operations. Refer to the demo source code for a full example.

Calling Find required obtaining the text of the page(s) using DocumentPage.GetText, the viewer can automatically perform this when the value of AutoGetText is true.

Find performs the action of selecting text in the page or document by calling SetSelectedTextItems.

Example

Start with the example created in DocumentViewer, remove all the code in the Example function and add the code below.

When the user clicks the Example button, we will try to find the word "LEAD" in the current page, and continue with finding next occurance until we reach the end of the page.

Copy Code  
Imports Leadtools
Imports Leadtools.Controls
Imports Leadtools.Documents
Imports Leadtools.Documents.UI
Imports Leadtools.Codecs
Imports Leadtools.Caching
Imports Leadtools.Annotations.Core
Imports Leadtools.Forms.Ocr

Dim text As DocumentViewerText = _documentViewer.Text
' First check if we have text for this page
Dim pageNumber As Integer = _documentViewer.CurrentPageNumber
If Not text.HasDocumentPageText(pageNumber) Then
   ' Get the text
   text.GetDocumentPageText(pageNumber)
End If

' Clear the last find data (if any)
text.ClearLastFindText()

' Find the first occurance of the word "LEAD" ignoring the case
Dim findText As New DocumentViewerFindText()
' The text
findText.Text = "LEAD"
' Ignore case
findText.MatchCase = False
' Any word that contains the phrase
findText.WholeWordsOnly = False
' In this page only
findText.PageNumber = _documentViewer.CurrentPageNumber
findText.GotoNextPage = False
' Do not go back to the beginning of the page
findText.Recursive = False
' Select the text if found
findText.AutoSelect = True
' Make sure we pan to it if the location is not in the current view
findText.AutoEnsureVisible = True

' Find it
If Not IsNothing(text.Find(findText, True, True)) Then
   Do
      MessageBox.Show("Found")

      ' Find next, using the same info so it continues from
      ' last location
   Loop While Not IsNothing(text.Find(text.LastFindText, False, True))
End If

MessageBox.Show("Reached the end of the page")
using Leadtools;
using Leadtools.Controls;
using Leadtools.Documents;
using Leadtools.Documents.UI;
using Leadtools.Codecs;
using Leadtools.Caching;
using Leadtools.Annotations.Core;
using Leadtools.Forms.Ocr;

var text = _documentViewer.Text;
// First check if we have text for this page
var pageNumber = _documentViewer.CurrentPageNumber;
if (!text.HasDocumentPageText(pageNumber))
{
   // Get the text
   text.GetDocumentPageText(pageNumber);
}

// Clear the last find data (if any)
text.ClearLastFindText();

// Find the first occurance of the word "LEAD" ignoring the case
var findText = new DocumentViewerFindText();
// The text
findText.Text = "LEAD";
// Ignore case
findText.MatchCase = false;
// Any word that contains the phrase
findText.WholeWordsOnly = false;
// In this page only
findText.PageNumber = _documentViewer.CurrentPageNumber;
findText.GotoNextPage = false;
// Do not go back to the beginning of the page
findText.Recursive = false;
// Select the text if found
findText.AutoSelect = true;
// Make sure we pan to it if the location is not in the current view
findText.AutoEnsureVisible = true;

// Find it
if (text.Find(findText, true, true) != null)
{
   do
   {
      MessageBox.Show("Found");

      // Find next, using the same info so it continues from
      // last location
   }
   while (text.Find(text.LastFindText, false, true) != null);
}

MessageBox.Show("Reached the end of the page");
Requirements

Target Platforms

See Also

Reference

DocumentViewerText Class
DocumentViewerText Members

Error processing SSI file
Leadtools.Documents.UI requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features