GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SetRectCoordinatesOnDocumentInches Method
The horizontal (X) coordinate (0-based) of the top left point, in inches, of the rectangle of selection, related to the current page.
The vertical (Y) coordinate (0-based) of the top left point, in inches, of the rectangle of selection, related to the current page.
The width, in inches, of the rectangle of selection.
The height, in inches, of the rectangle of selection.
Example





In This Topic
SetRectCoordinatesOnDocumentInches Method (GdViewer)
In This Topic
Determines the rectangle of area selection refering to the document pages area. This method sets the specified coordinates and dimensions, in inches, to identify the rectangle of selection related to the document displayed in the GdViewer control. The specified rectangle is immediately drawn on the displayed page using the predefined parameters. Please ensure, that all given values correspond to the actual document pages area.

Be aware that the rectangle of selection always relates to the displayed document. On the other hand, you can specify the border size of this rectangle using the RectBorderSize property and the border color of this rectangle using the RectBorderColor property to be applied permanently.

Syntax
'Declaration
 
Public Sub SetRectCoordinatesOnDocumentInches( _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) 
public void SetRectCoordinatesOnDocumentInches( 
   float Left,
   float Top,
   float Width,
   float Height
)
public procedure SetRectCoordinatesOnDocumentInches( 
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
); 
public function SetRectCoordinatesOnDocumentInches( 
   Left : float,
   Top : float,
   Width : float,
   Height : float
);
public: void SetRectCoordinatesOnDocumentInches( 
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
void SetRectCoordinatesOnDocumentInches( 
   float Left,
   float Top,
   float Width,
   float Height
) 

Parameters

Left
The horizontal (X) coordinate (0-based) of the top left point, in inches, of the rectangle of selection, related to the current page.
Top
The vertical (Y) coordinate (0-based) of the top left point, in inches, of the rectangle of selection, related to the current page.
Width
The width, in inches, of the rectangle of selection.
Height
The height, in inches, of the rectangle of selection.
Remarks
Be aware that you are allowed to define only one rectangle of selection within the GdViewer control. Likewise, the rectangle of selection always relates to the currently displayed document, meaning that without displaying some document you cannot specify the new rectangle of selection.

Just to remind you, that all coordinates are 0-based with the origin being in the top left corner in the document pages area and they are related to the current page determined by the CurrentPage property.

Example
How to define the rectangle of selection on the displayed document.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
            
'Setting some custom properties for the rectangle of selection.
GdViewer1.RectBorderColor = GdViewer1.ARGB(255, 69, 0)
GdViewer1.RectBorderSize = 2
            
If GdViewer1.SelectAllText() = GdPictureStatus.OK Then
    Dim regions As RectangleF() = GdViewer1.GetSelectedTextRegions()
    If (GdViewer1.GetStat() = GdPictureStatus.OK) AndAlso (regions.Count() > 0) Then
        'The first region surely exists.
        Dim rect As RectangleF = regions.ElementAt(0)
        GdViewer1.SetRectCoordinatesOnDocumentInches(rect.Left, rect.Top, rect.Width, rect.Height)
        GdViewer1.CenterOnRect()
    Else
        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInches")
    End If
Else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInches")
End If
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
            
//Setting some custom properties for the rectangle of selection.
GdViewer1.RectBorderColor = GdViewer1.ARGB(255, 69, 0);
GdViewer1.RectBorderSize = 2;
            
if (GdViewer1.SelectAllText() == GdPictureStatus.OK)
{
    RectangleF[] regions = GdViewer1.GetSelectedTextRegions();
    if ((GdViewer1.GetStat() == GdPictureStatus.OK) && (regions.Count() > 0))
    {
        //The first region surely exists.
        RectangleF rect = regions.ElementAt(0);
        GdViewer1.SetRectCoordinatesOnDocumentInches(rect.Left, rect.Top, rect.Width, rect.Height);
        GdViewer1.CenterOnRect();
    }
    else
        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInches");
}
else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInches");
See Also