Example





In This Topic
GdPicture14.WPF Namespace / GdViewer Class / GetSelectedText Method

GetSelectedText Method (GdViewer)

In This Topic
Returns the last text selected by the user. This text is stored until you call the ClearSelectedText method to release it.
Syntax
'Declaration
 
Public Function GetSelectedText() As String
public string GetSelectedText()
public function GetSelectedText(): String; 
public function GetSelectedText() : String;
public: string* GetSelectedText(); 
public:
String^ GetSelectedText(); 

Return Value

The text, that user has selected last time. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
Just to inform you, that no new text selection is made using this method. You can use the ClearSelectedText method to release the text selection data.
Example
How to select all text on the currently displayed page in the viewer, how to extract it and how to clear the selection.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    'Enabling text selection.
    GdViewer1.EnableTextSelection = True
    If GdViewer1.SelectAllText() = GdPictureStatus.OK Then
        Dim selected_text As String = GdViewer1.GetSelectedText()
        If GdViewer1.GetStat() = GdPictureStatus.OK Then
            'Do your stuff with the selected_text.
            GdViewer1.ClearSelectedText()
        Else
            MessageBox.Show("The text can't be extracted. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText")
        End If
    Else
        MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    //Enabling text selection.
    GdViewer1.EnableTextSelection = true;
    if (GdViewer1.SelectAllText() == GdPictureStatus.OK)
    {
        string selected_text = GdViewer1.GetSelectedText();
        if (GdViewer1.GetStat() == GdPictureStatus.OK)
        {
            //Do your stuff with the selected_text.
            GdViewer1.ClearSelectedText();
        }
        else
            MessageBox.Show("The text can't be extracted. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText");
    }
    else
        MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedText");
See Also