The number of the page to search for text. It must be a value from 1 to the value of the PageCount property.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Example





In This Topic
GdPicture14 Namespace / GdViewer Class / GetTextOccurrenceCountRegex Method

GetTextOccurrenceCountRegex Method (GdViewer)

In This Topic
Searches for an occurrence of a given regex pattern within the specified page of the document displayed in the GdViewer control according to the parameters you have specified. If the format of the displayed document is other than supported text-based formats, which currently are DOCX, TXT, RTF and PDF, the method will fail.
Searches for an occurrence of a given text expression within the specified page of the document displayed in the GdViewer control according to the parameters you have specified. You can select either the Ordinal or the InvariantCulture comparison when searching.
Syntax
'Declaration
 
Public Function GetTextOccurrenceCountRegex( _
   ByVal Page As Integer, _
   ByVal Text As String, _
   ByVal CaseSensitive As Boolean _
) As Integer
public int GetTextOccurrenceCountRegex( 
   int Page,
   string Text,
   bool CaseSensitive
)
public function GetTextOccurrenceCountRegex( 
    Page: Integer;
    Text: String;
    CaseSensitive: Boolean
): Integer; 
public function GetTextOccurrenceCountRegex( 
   Page : int,
   Text : String,
   CaseSensitive : boolean
) : int;
public: int GetTextOccurrenceCountRegex( 
   int Page,
   string* Text,
   bool CaseSensitive
) 
public:
int GetTextOccurrenceCountRegex( 
   int Page,
   String^ Text,
   bool CaseSensitive
) 

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
CaseSensitive
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.

Return Value

The number of occurrences if the given text expression has been found on the current page according to the specified parameters. 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.
Example
How to search for the specified regex pattern
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
Sub MySearchText(ByVal RegexPattern As String)
    Dim page As Integer = 1, occurrence As Integer = 0
    Dim status As GdPictureStatus = GdPictureStatus.OK
    While (status = GdPictureStatus.OK) AndAlso (page <= GdViewer1.PageCount)
        occurrence = GdViewer1.GetTextOccurrenceCountRegex(page, RegexPattern, False)
        status = GdViewer1.GetStat()
        If status = GdPictureStatus.OK Then
            If occurrence > 0 Then Exit While
            page += 1
        End If
    End While
    If (status = GdPictureStatus.OK) AndAlso (occurrence > 0) Then GdViewer1.DisplayPage(page)
End Sub
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
void MySearchText(string RegexPattern)
{
    int page = 1, occurrence = 0;
    GdPictureStatus status = GdPictureStatus.OK;
    while ((status == GdPictureStatus.OK) && (page <= GdViewer1.PageCount))
    {
        occurrence = GdViewer1.GetTextOccurrenceCount(page, RegexPattern, false);
        status = GdViewer1.GetStat();
        if (status == GdPictureStatus.OK)
        {
            if (occurrence > 0) break;
            page++;
        }
    }
    if ((status == GdPictureStatus.OK) && (occurrence > 0))
        GdViewer1.DisplayPage(page);
}
See Also