Output parameter. The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the current page.
Output parameter. The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the current page.
Output parameter. The width, in pixels, of the rectangle of selection.
Output parameter. The height, in pixels, of the rectangle of selection.
Example





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

GetRectCoordinatesOnDocumentPixel Method

In This Topic
Gets data of the currently defined rectangle of area selection refering to the document pages area. This method gets the rectangle's coordinates and dimensions, in pixels, which determine the rectangle of selection related to the document displayed in the GdViewer control. The resulting values correspond to the actual document pages area.

Be aware that the rectangle of selection always relates to the displayed document. You can find out, if this rectangle is defined and drawn, using the IsRect method.

Syntax
'Declaration
 
Public Sub GetRectCoordinatesOnDocumentPixel( _
   ByRef Left As Double, _
   ByRef Top As Double, _
   ByRef Width As Double, _
   ByRef Height As Double _
) 
public void GetRectCoordinatesOnDocumentPixel( 
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
)
public procedure GetRectCoordinatesOnDocumentPixel( 
   var  Left: Double;
   var  Top: Double;
   var  Width: Double;
   var  Height: Double
); 
public function GetRectCoordinatesOnDocumentPixel( 
   Left : double,
   Top : double,
   Width : double,
   Height : double
);
public: void GetRectCoordinatesOnDocumentPixel( 
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
) 
public:
void GetRectCoordinatesOnDocumentPixel( 
   double% Left,
   double% Top,
   double% Width,
   double% Height
) 

Parameters

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

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 enlarge the specified 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 = Color.FromArgb(255, 255, 69, 0)
GdViewer1.RectBorderSize = 2
            
If GdViewer1.SelectAllText() = GdPictureStatus.OK Then
    Dim regions As Rect() = GdViewer1.GetSelectedTextRegions()
            
    If (GdViewer1.GetStat() = GdPictureStatus.OK) AndAlso (regions.Length > 0) Then
        'The first region surely exists.
        Dim rect As Rect = regions(0)
        Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
        GdViewer1.SetRectCoordinatesOnDocumentInch(rect.Left, rect.Top, rect.Width, rect.Height)
        GdViewer1.GetRectCoordinatesOnDocumentPixel(left, top, width, height)
        GdViewer1.SetRectCoordinatesOnDocumentPixel(left - 2, top - 2, width + 4, height + 4)
        GdViewer1.CenterOnRect()
    Else
        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectCoordinatesOnDocumentPixel")
    End If
Else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectCoordinatesOnDocumentPixel")
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 = Color.FromArgb(255, 255, 69, 0);
GdViewer1.RectBorderSize = 2;
            
if (GdViewer1.SelectAllText() == GdPictureStatus.OK)
{
    Rect[] regions = GdViewer1.GetSelectedTextRegions();
    if ((GdViewer1.GetStat() == GdPictureStatus.OK) && (regions.Length > 0))
    {
        //The first region surely exists.
        Rect rect = regions[0];
        double left = 0, top = 0, width = 0, height = 0;
        GdViewer1.SetRectCoordinatesOnDocumentInch(rect.Left, rect.Top, rect.Width, rect.Height);
        GdViewer1.GetRectCoordinatesOnDocumentPixel(ref left, ref top, ref width, ref height);
        GdViewer1.SetRectCoordinatesOnDocumentPixel(left - 2, top - 2, width + 4, height + 4);
        GdViewer1.CenterOnRect();
    }
    else
        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectCoordinatesOnDocumentPixel");
}
else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectCoordinatesOnDocumentPixel");
See Also