SearchTextRegex(Int32,String,Int32,Boolean,IEnumerable<RectangleF>) Method
In This Topic
Searches for an occurrence of a given regular expression pattern within the defined page of the document displayed in the GdViewer control according to the parameters you have specified. This method returns the bounding boxes (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 SearchTextRegex( _
ByVal As Integer, _
ByVal As String, _
ByVal As Integer, _
ByVal As Boolean, _
ByRef As IEnumerable(Of RectangleF) _
) As Boolean
public bool SearchTextRegex(
int ,
string ,
int ,
bool ,
out IEnumerable<RectangleF>
)
public function SearchTextRegex(
: Integer;
: String;
: Integer;
: Boolean;
Out : IEnumerable
): Boolean;
public function SearchTextRegex(
: int,
: String,
: int,
: boolean,
: IEnumerable
) : boolean;
public: bool SearchTextRegex(
int ,
string* ,
int ,
bool ,
[PARAMFLAG::Out] IEnumerable<RectangleF>*
)
public:
bool SearchTextRegex(
int ,
String^ ,
int ,
bool ,
[Out] IEnumerable<RectangleF>^
)
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.
- Pattern
- The textregular expression pattern to search for.
- Occurence
- 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.
- BoundingArray
- Output parameter. If the searched expression has been found, this is the list of bounding box rectangle definined 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 search for given text within the current page using different parameters.
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.RemoveAllRegions();
bool text_found = GdViewer1.SearchText(text_to_find, 1, true, out IEnumerable<RectangleF> boundingArray);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
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 search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText");
Example
How to search for given text within the current page using different parameters.
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.RemoveAllRegions();
bool text_found = GdViewer1.SearchText(text_to_find, 1, true, out IEnumerable boundingArray);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
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 search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SearchText");
See Also