GdPicture.NET.14 (COM - ActiveX)~GdPicture14_namespace / GdPicture.NET.14 (COM - ActiveX)~GdPicture14.GdViewer / GetTextOccurrenceCount_2 Method
The number of the page to search for text. It must be a value from 1 to the value of the GdViewer.PageCount property.
The text expression to search for.
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.
Example





In This Topic
    GetTextOccurrenceCount_2 Method (GdViewer)
    In This Topic
    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. 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.

    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 Function GetTextOccurrenceCount_2( _
       ByVal Page As Integer, _
       ByVal Text As String, _
       ByVal CaseSensitive As Boolean, _
       ByVal WholeWords As Boolean, _
       ByVal OrdinalComparison As Boolean _
    ) As Integer
    public int GetTextOccurrenceCount_2( 
       int Page,
       string Text,
       bool CaseSensitive,
       bool WholeWords,
       bool OrdinalComparison
    )
    public function GetTextOccurrenceCount_2( 
        Page: Integer;
        Text: String;
        CaseSensitive: Boolean;
        WholeWords: Boolean;
        OrdinalComparison: Boolean
    ): Integer; 
    public function GetTextOccurrenceCount_2( 
       Page : int,
       Text : String,
       CaseSensitive : boolean,
       WholeWords : boolean,
       OrdinalComparison : boolean
    ) : int;
    public: int GetTextOccurrenceCount_2( 
       int Page,
       string* Text,
       bool CaseSensitive,
       bool WholeWords,
       bool OrdinalComparison
    ) 
    public:
    int GetTextOccurrenceCount_2( 
       int Page,
       String^ Text,
       bool CaseSensitive,
       bool WholeWords,
       bool OrdinalComparison
    ) 

    Parameters

    Page
    The number of the page to search for text. It must be a value from 1 to the value of the GdViewer.PageCount property.
    Text
    The text expression to search for.
    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.

    Return Value

    The number of occurrences if the given text expression has been found on the current page according to the specified parameters. The GdViewer.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 text applying the Ordinal comparison.
    'We assume that the GdViewer1 control has been properly integrated
    'and your document has been properly displayed as well.
    Sub MySearchText(ByVal TextToSearch 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.GetTextOccurrenceCount_2(page, TextToSearch, False, False, True)
            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 TextToSearch)
    {
        int page = 1, occurrence = 0;
        GdPictureStatus status = GdPictureStatus.OK;
        while ((status == GdPictureStatus.OK) && (page <= GdViewer1.PageCount))
        {
            occurrence = GdViewer1.GetTextOccurrenceCount_2(page, TextToSearch, false, false, true);
            status = GdViewer1.GetStat();
            if (status == GdPictureStatus.OK)
            {
                if (occurrence > 0) break;
                page++;
            }
        }
        if ((status == GdPictureStatus.OK) && (occurrence > 0))
            GdViewer1.DisplayPage(page);
    }
    See Also