GetRectLeftOnDocument Method (GdViewer)
In This Topic
Returns the horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of area selection, related to the current page. The resulting coordinate corresponds to the actual document pages area of the document displayed in the GdViewer control. You can determine, if the rectangle of selection is currently defined and drawn within the control, using the
IsRect method.
Syntax
'Declaration
Public Function GetRectLeftOnDocument() As Integer
public int GetRectLeftOnDocument()
public function GetRectLeftOnDocument(): Integer;
public function GetRectLeftOnDocument() : int;
public: int GetRectLeftOnDocument();
public:
int GetRectLeftOnDocument();
Return Value
The horizontal coordinate of the top left point, in pixels, of the rectangle of selection, related to the current page.
Example
How to compare the coordinates of the rectangle of selection related to the document pages area with those related to the viewer area.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
GdViewer1.ClearRect()
Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 1, True)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If text_found AndAlso GdViewer1.IsRect() Then
GdViewer1.CenterOnRect()
'Finding coordinates to compare.
Dim leftViewer As Integer = GdViewer1.GetRectLeftOnViewer()
Dim leftDoc As Integer = GdViewer1.GetRectLeftOnDocument()
Dim topViewer As Integer = GdViewer1.GetRectTopOnViewer()
Dim topDoc As Integer = GdViewer1.GetRectTopOnDocument()
MessageBox.Show("The location point on the viewer is " + leftViewer + ", " + topViewer + "." + vbLf +
"The location point on the document's page is " + leftDoc + ", " + topDoc + ".", "GdViewer.GetRectLeftOnDocument")
Else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRectLeftOnDocument")
End If
Else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.ClearRect();
bool text_found = GdViewer1.SearchText(text_to_find, 1, true);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (text_found && GdViewer1.IsRect())
{
GdViewer1.CenterOnRect();
//Finding coordinates to compare.
int leftViewer = GdViewer1.GetRectLeftOnViewer();
int leftDoc = GdViewer1.GetRectLeftOnDocument();
int topViewer = GdViewer1.GetRectTopOnViewer();
int topDoc = GdViewer1.GetRectTopOnDocument();
MessageBox.Show("The location point on the viewer is " + leftViewer + ", " + topViewer +
".\nThe location point on the document's page is " + leftDoc + ", " + topDoc + ".", "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument");
Example
How to compare the coordinates of the rectangle of selection related to the document pages area with those related to the viewer area.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
GdViewer1.ClearRect()
Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 1, True)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If text_found AndAlso GdViewer1.IsRect() Then
GdViewer1.CenterOnRect()
'Finding coordinates to compare.
Dim leftViewer As Integer = GdViewer1.GetRectLeftOnViewer()
Dim leftDoc As Integer = GdViewer1.GetRectLeftOnDocument()
Dim topViewer As Integer = GdViewer1.GetRectTopOnViewer()
Dim topDoc As Integer = GdViewer1.GetRectTopOnDocument()
MessageBox.Show("The location point on the viewer is " + leftViewer + ", " + topViewer + "." + vbLf +
"The location point on the document's page is " + leftDoc + ", " + topDoc + ".", "GdViewer.GetRectLeftOnDocument")
Else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRectLeftOnDocument")
End If
Else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.ClearRect();
bool text_found = GdViewer1.SearchText(text_to_find, 1, true);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (text_found && GdViewer1.IsRect())
{
GdViewer1.CenterOnRect();
//Finding coordinates to compare.
int leftViewer = GdViewer1.GetRectLeftOnViewer();
int leftDoc = GdViewer1.GetRectLeftOnDocument();
int topViewer = GdViewer1.GetRectTopOnViewer();
int topDoc = GdViewer1.GetRectTopOnDocument();
MessageBox.Show("The location point on the viewer is " + leftViewer + ", " + topViewer +
".\nThe location point on the document's page is " + leftDoc + ", " + topDoc + ".", "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRectLeftOnDocument");
See Also