A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method.
Example





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

GetRegionWidth Method (GdViewer)

In This Topic
Gets the width of the highlighted region's rectangle, in inches, related to the actual document (meaning the document pages area). The highlighted region is specified by its unique identifier related to the document currently displayed in the GdViewer control. These regions, if present, determines the currently defined highlighted regions on the displayed document.

You can define the width of the region's rectangle when adding regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method or directly using the SetRegionWidth method.

Syntax
'Declaration
 
Public Function GetRegionWidth( _
   ByVal RegionID As Integer _
) As Double
public double GetRegionWidth( 
   int RegionID
)
public function GetRegionWidth( 
    RegionID: Integer
): Double; 
public function GetRegionWidth( 
   RegionID : int
) : double;
public: double GetRegionWidth( 
   int RegionID
) 
public:
double GetRegionWidth( 
   int RegionID
) 

Parameters

RegionID
A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method.

Return Value

The width, in inches, of the highlighted region's rectangle, related to the actual document. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
Be aware that if the required region does not exist, the method will fail.

Please note that the returned value corresponds to the actual document area, it is not related to the GdViewer control area.

Example
How to use region's coordinates to add new highlighted region.
'We assume that the GdViewer1 control has been properly integrated.
'Please use the multipage document for this example.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    GdViewer1.RemoveAllRegions()
    GdViewer1.DisplayPage(1)
    'Determining highlighted regions according to the given text.
    Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found AndAlso (GdViewer1.RegionCount() > 0) Then
            'The first region surely exists.
            Dim regID As Integer = GdViewer1.GetRegionID(0)
            GdViewer1.SetRegionName(regID, "Region1")
            GdViewer1.SetRegionColor(regID, Color.FromArgb(255, 0, 191, 255))
            'Taking properties from the first region.
            Dim left As Double = GdViewer1.GetRegionLeft(regID), top As Single = GdViewer1.GetRegionTop(regID)
            Dim width As Double = GdViewer1.GetRegionWidth(regID), height As Single = GdViewer1.GetRegionHeight(regID)
            For p As Integer = 2 To GdViewer1.PageCount
                'Adding regions on the same position on each page as the first one is (with the different color)
                'to compare them with those found by the toolkit using the SearchText() method if any exists.
                regID = GdViewer1.AddRegion("Region" + p.ToString(), left, top, width, height, Color.FromArgb(255, 0, 191, 255), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply)
                GdViewer1.SetRegionPage(regID, p)
            Next
            GdViewer1.Redraw()
            'Now you can scroll the viewer to find the newly added regions.
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.GetRegionWidth")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionWidth")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionWidth")
End If
//We assume that the GdViewer1 control has been properly integrated.
//Please use the multipage document for this example.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    GdViewer1.RemoveAllRegions();
    GdViewer1.DisplayPage(1);
    //Determining highlighted regions according to the given text.
    bool text_found = GdViewer1.SearchText(text_to_find, 0, true, true);
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (text_found && (GdViewer1.RegionCount()> 0))
        {
            //The first region surely exists.
            int regID = GdViewer1.GetRegionID(0);
            GdViewer1.SetRegionName(regID, "Region1");
            GdViewer1.SetRegionColor(regID, Color.FromArgb(255, 0, 191, 255));
            //Taking properties from the first region.
            double left = GdViewer1.GetRegionLeft(regID), top = GdViewer1.GetRegionTop(regID);
            double width = GdViewer1.GetRegionWidth(regID), height = GdViewer1.GetRegionHeight(regID);
            for (int p = 2; p <= GdViewer1.PageCount; p++)
            {
                //Adding regions on the same position on each page as the first one is (with the different color)
                //to compare them with those found by the toolkit using the SearchText() method if any exists.
                regID = GdViewer1.AddRegion("Region" + p.ToString(), left, top, width, height, Color.FromArgb(255, 0, 191, 255), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply);
                GdViewer1.SetRegionPage(regID, p);
            }
            GdViewer1.Redraw();
            //Now you can scroll the viewer to find the newly added regions.
        }
        else
            MessageBox.Show("The given text has not been found.", "GdViewer.GetRegionWidth");
    }
    else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionWidth");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionWidth");
See Also