SearchText(Int32,String,Int32,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.
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 As Integer, _
ByVal As String, _
ByVal As Integer, _
ByVal As Boolean, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single _
) As Boolean
public bool SearchText(
int ,
string ,
int ,
bool ,
ref float ,
ref float ,
ref float ,
ref float
)
public function SearchText(
: Integer;
: String;
: Integer;
: Boolean;
var : Single;
var : Single;
var : Single;
var : Single
): Boolean;
public function SearchText(
: int,
: String,
: int,
: boolean,
: float,
: float,
: float,
: float
) : boolean;
public: bool SearchText(
int ,
string* ,
int ,
bool ,
ref float ,
ref float ,
ref float ,
ref float
)
public:
bool SearchText(
int ,
String^ ,
int ,
bool ,
float% ,
float% ,
float% ,
float%
)
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.
- 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 pointof 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.
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 bool = False
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, 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, 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");
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 bool = False
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, 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, 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
Reference
GdViewer Class
GdViewer Members
Overload List
PageCount Property
SearchText(Int32,String,Int32,Boolean,Boolean,Boolean,Single,Single,Single,Single) Method
GetStat Method
GetTextOccurrenceCount(Int32,String,Boolean,Boolean) Method
GetSelectedTextRegions Method
GetSelectedText Method
ClearSelectedText Method