GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SearchText Method / SearchText(Int32,String,Int32,Boolean,Boolean,Boolean,Single,Single,Single,Single) 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 if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false. An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
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.
Example





In This Topic
SearchText(Int32,String,Int32,Boolean,Boolean,Boolean,Single,Single,Single,Single) Method
In This Topic
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.

You can benefit from selecting the comparison option using this method, in other words, you can search respecting accents or not in the given text expression.

Syntax
'Declaration
 
Public Overloads Function SearchText( _
   ByVal Page As Integer, _
   ByVal Text As String, _
   ByVal Occurrence As Integer, _
   ByVal CaseSensitive As Boolean, _
   ByVal WholeWords As Boolean, _
   ByVal OrdinalComparison As Boolean, _
   ByRef Left As Single, _
   ByRef Top As Single, _
   ByRef Width As Single, _
   ByRef Height As Single _
) As Boolean
public bool SearchText( 
   int Page,
   string Text,
   int Occurrence,
   bool CaseSensitive,
   bool WholeWords,
   bool OrdinalComparison,
   ref float Left,
   ref float Top,
   ref float Width,
   ref float Height
)
public function SearchText( 
    Page: Integer;
    Text: String;
    Occurrence: Integer;
    CaseSensitive: Boolean;
    WholeWords: Boolean;
    OrdinalComparison: Boolean;
   var  Left: Single;
   var  Top: Single;
   var  Width: Single;
   var  Height: Single
): Boolean; 
public function SearchText( 
   Page : int,
   Text : String,
   Occurrence : int,
   CaseSensitive : boolean,
   WholeWords : boolean,
   OrdinalComparison : boolean,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : boolean;
public: bool SearchText( 
   int Page,
   string* Text,
   int Occurrence,
   bool CaseSensitive,
   bool WholeWords,
   bool OrdinalComparison,
   ref float Left,
   ref float Top,
   ref float Width,
   ref float Height
) 
public:
bool SearchText( 
   int Page,
   String^ Text,
   int Occurrence,
   bool CaseSensitive,
   bool WholeWords,
   bool OrdinalComparison,
   float% Left,
   float% Top,
   float% Width,
   float% 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 if you want to apply case-sensitive search, otherwise set it to false.
WholeWords
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
OrdinalComparison
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false. An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
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 if the given text expression has been found on the required page according to the specified parameters, otherwise false. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only useful for text-based document formats, like DOCX, TXT, RTF and PDF.

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 Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
    Dim text_found As Boolean = False
    GdViewer1.RemoveAllRegions()
    While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, True, True, left, top, width, height)
        text_found = True
        GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGB(255, 176, 224, 230))
        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;
    float left = 0, top = 0, width = 0, height = 0;
    bool text_found = false;
    GdViewer1.RemoveAllRegions();
    while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, true, true, ref left, ref top, ref width, ref height))
    {
        text_found = true;
        GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGB(255, 176, 224, 230));
        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