Example





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

GetSelectedTextRegions Method (GdViewer)

In This Topic
Returns all rectangle areas, related to the current page, that represent the regions bounding the last text selected by the user. Each region is defined by its top left coordinates and by its width and height expressed in inches. These regions are stored until you call the ClearSelectedText method to release them.
Syntax
'Declaration
 
Public Function GetSelectedTextRegions() As Rect()
public Rect[] GetSelectedTextRegions()
public function GetSelectedTextRegions(): array of Rect; 
public function GetSelectedTextRegions() : Rect[];
public: Rect[]* GetSelectedTextRegions(); 
public:
array<Rect>^ GetSelectedTextRegions(); 

Return Value

The regions, related to the current page, which bound the text, that user has selected last time. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
Please note that rectangle coordinates are expressed in inches starting from the most top-left position on the current page.

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 and how to get the selected text regions.
'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 regions As Rect() = GdViewer1.GetSelectedTextRegions()
        If GdViewer1.GetStat() = GdPictureStatus.OK Then
            MessageBox.Show("The number of selected text regions is: " + regions.Length.ToString(), "GdViewer.GetSelectedTextRegions")
            'Do your stuff with the regions.
            GdViewer1.ClearSelectedText()
        Else
            MessageBox.Show("The text can't be extracted. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions")
        End If
    Else
        MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions")
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)
    {
        Rect[] regions = GdViewer1.GetSelectedTextRegions();
        if (GdViewer1.GetStat() == GdPictureStatus.OK)
        {
            MessageBox.Show("The number of selected text regions is: " + regions.Length.ToString(), "GdViewer.GetSelectedTextRegions");
            //Do your stuff with the regions.
            GdViewer1.ClearSelectedText();
        }
        else
            MessageBox.Show("The text can't be extracted. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions");
    }
    else
        MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetSelectedTextRegions");
See Also