SetRectCoordinatesOnDocumentInch Method
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 SetRectCoordinatesOnDocumentInch( _
ByVal As Double, _
ByVal As Double, _
ByVal As Double, _
ByVal As Double _
)
public void SetRectCoordinatesOnDocumentInch(
double ,
double ,
double ,
double
)
public procedure SetRectCoordinatesOnDocumentInch(
: Double;
: Double;
: Double;
: Double
);
public function SetRectCoordinatesOnDocumentInch(
: double,
: double,
: double,
: double
);
public: void SetRectCoordinatesOnDocumentInch(
double ,
double ,
double ,
double
)
public:
void SetRectCoordinatesOnDocumentInch(
double ,
double ,
double ,
double
)
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.
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 = 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.SetRectCoordinatesOnDocumentInch")
End If
Else
MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInch")
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.SetRectCoordinatesOnDocumentInch");
}
else
MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInch");
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 = 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.SetRectCoordinatesOnDocumentInch")
End If
Else
MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInch")
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.SetRectCoordinatesOnDocumentInch");
}
else
MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnDocumentInch");
See Also