GdPicture.NET Reference Guide
SearchText(Int32,String,Int32,Boolean,Double,Double,Double,Double) Method
Example 





GdPicture14.WPF Namespace > GdViewer Class > SearchText Method : SearchText(Int32,String,Int32,Boolean,Double,Double,Double,Double) Method
The number of the page to search for text. It must be a value from 1 to the value of the PageCount property.
The text expression to search for.
The occurrence of the searched expression on the required page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.

The value of 0 is not accepted, it will always be converted to 1. Please note that the occurrence is always related to the specified page.

Set this parameter to True/true if you want to apply case-sensitive search, otherwise set it to False/false.
Output parameter. If the searched expression has been found, this is the position of the horizontal (X) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the position of the vertical (Y) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the width of the bounding box surrounding the expression, in inches.
Output parameter. If the searched expression has been found, this is the height of the bounding box surrounding the expression, in inches.
Searches for an occurrence of a given text expression within the defined page of the document displayed in the GdViewer control according to the parameters you have specified. This method returns the bounding box (rectangle) surrounding the searched expression on the required page defined by its top left coordinates and by its width and height in inches, if the expression has been found. This occurrence is not highlighted using this method.

Be aware that this method uses InvariantCulture comparison when searching. It means, that characters are comparing using culture-sensitive sort rules and the invariant culture, in other words this method respects accents when searching.

Syntax
'Declaration
 
Public Overloads Function SearchText( _
   ByVal Page As Integer, _
   ByVal Text As String, _
   ByVal Occurrence As Integer, _
   ByVal CaseSensitive As Boolean, _
   ByRef Left As Double, _
   ByRef Top As Double, _
   ByRef Width As Double, _
   ByRef Height As Double _
) As Boolean
public bool SearchText( 
   int Page,
   string Text,
   int Occurrence,
   bool CaseSensitive,
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
)
public function SearchText( 
    Page: Integer;
    Text: String;
    Occurrence: Integer;
    CaseSensitive: Boolean;
   var  Left: Double;
   var  Top: Double;
   var  Width: Double;
   var  Height: Double
): Boolean; 
public function SearchText( 
   Page : int,
   Text : String,
   Occurrence : int,
   CaseSensitive : boolean,
   Left : double,
   Top : double,
   Width : double,
   Height : double
) : boolean;
public: bool SearchText( 
   int Page,
   string* Text,
   int Occurrence,
   bool CaseSensitive,
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
) 

Parameters

Page
The number of the page to search for text. It must be a value from 1 to the value of the PageCount property.
Text
The text expression to search for.
Occurrence
The occurrence of the searched expression on the required page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.

The value of 0 is not accepted, it will always be converted to 1. Please note that the occurrence is always related to the specified page.

CaseSensitive
Set this parameter to True/true if you want to apply case-sensitive search, otherwise set it to False/false.
Left
Output parameter. If the searched expression has been found, this is the position of the horizontal (X) coordinate of the top left point of its surrounding bounding box, in inches.
Top
Output parameter. If the searched expression has been found, this is the position of the vertical (Y) coordinate of the top left point of its surrounding bounding box, in inches.
Width
Output parameter. If the searched expression has been found, this is the width of the bounding box surrounding the expression, in inches.
Height
Output parameter. If the searched expression has been found, this is the height of the bounding box surrounding the expression, in inches.

Return Value

True/true if the given text expression has been found on the required page according to the specified parameters, otherwise False/false. Please always use the GetStat method to determine if this method has been successful.
Remarks
Please note that this method is only useful for text-based document formats, like DOCX, TXT, RTF and PDF.

Be aware that this method respects accents when searching. You can use the overloaded SearchText(Int32,String,Int32,Boolean,Boolean,Boolean,Double,Double,Double,Double) method for searching not respecting accents.

Just to inform you, that this method does not change the currently determined highlighted regions or the currently defined rectangle of selection. At the same, the found occurrence of the given text is not highlighted using this method.

Example
How to find out regions with the given text and how to highlight them using the specified color.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    Dim occurrence As Integer = 1
    Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
    Dim text_found As Boolean = False
    GdViewer1.RemoveAllRegions()
    While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, left, top, width, height)
        text_found = True
        GdViewer1.AddRegion("Region" + occurrence.ToString(), left, top, width, height, Color.FromArgb(255, 240, 128, 128), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply)
        occurrence = occurrence + 1
    End While
    If text_found Then
        GdViewer1.Redraw()
        MessageBox.Show("The number of highlighted regions: " + GdViewer1.RegionCount().ToString(), "GdViewer.SearchText")
    Else
        MessageBox.Show("The given text has not been found.", "GdViewer.SearchText")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    int occurrence = 1;
    double left = 0, top = 0, width = 0, height = 0;
    bool text_found = false;
    GdViewer1.RemoveAllRegions();
    while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, ref left, ref top, ref width, ref height))
    {
        text_found = true;
        GdViewer1.AddRegion("Region" + occurrence.ToString(), left, top, width, height, Color.FromArgb(255, 240, 128, 128), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply);
        occurrence = occurrence + 1;
    }
    if (text_found)
    {
        GdViewer1.Redraw();
        MessageBox.Show("The number of highlighted regions: " + GdViewer1.RegionCount().ToString(), "GdViewer.SearchText");
    }
    else
        MessageBox.Show("The given text has not been found.", "GdViewer.SearchText");                    
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText");
See Also

Reference

GdViewer Class
GdViewer Members
Overload List
GetTextOccurrenceCount(Int32,String,Boolean,Boolean) Method
GetSelectedTextRegions Method
GetSelectedText Method
ClearSelectedText Method