GetDisplayedArea Method (GdViewer)
In This Topic
Returns coordinates and dimensions, in pixels, of the document's visible area within the control. The resulting rectangle relates to the current page
of the document displayed in the GdViewer control and the coordinates correspond to the actual document pages area of the currently displayed page.
Syntax
'Declaration
Public Sub GetDisplayedArea( _
ByRef As Integer, _
ByRef As Integer, _
ByRef As Integer, _
ByRef As Integer _
)
public void GetDisplayedArea(
ref int ,
ref int ,
ref int ,
ref int
)
public procedure GetDisplayedArea(
var : Integer;
var : Integer;
var : Integer;
var : Integer
);
public function GetDisplayedArea(
: int,
: int,
: int,
: int
);
public: void GetDisplayedArea(
ref int ,
ref int ,
ref int ,
ref int
)
public:
void GetDisplayedArea(
int% ,
int% ,
int% ,
int%
)
Parameters
- Left
- Output parameter. The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the document's area visible in the control.
- Top
- Output parameter. The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the document's area visible in the control.
- Width
- Output parameter. The width, in pixels, of the visible area rectangle.
- Height
- Output parameter. The height, in pixels, of the visible area rectangle.
Example
The first example shows you how to determine the fully visible rectangle of the current page within the viewer.
The second example demonstrates how to copy the content of this visible area to the clipboard.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0
GdViewer1.GetDisplayedArea(left, top, width, height)
Dim leftDoc As Integer = GdViewer1.GetDocumentLeft()
Dim topDoc As Integer = GdViewer1.GetDocumentTop()
MessageBox.Show("Page width (X): " + GdViewer1.PageWidth + vbCrLf + "Page height (Y): " + GdViewer1.PageHeight + vbCrLf + vbCrLf +
"Document: top-left point (X,Y): " + leftDoc + ", " + topDoc + vbCrLf +
"Displayed area:" + vbCrLf + " top-left point (X,Y): " + left + ", " + top + vbCrLf + " width: " + width + " height: " + height, "GdViewer.GetDisplayedArea")
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
int left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);
int leftDoc = GdViewer1.GetDocumentLeft();
int topDoc = GdViewer1.GetDocumentTop();
MessageBox.Show("Page width (X): " + GdViewer1.PageWidth + "\nPage height (Y): " + GdViewer1.PageHeight + "\n\n" +
"Document: top-left point (X,Y): " + leftDoc + ", " + topDoc + "\n" +
"Displayed area:\n top-left point (X,Y): " + left + ", " + top + "\n width: " + width + " height: " + height, "GdViewer.GetDisplayedArea");
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0
GdViewer1.GetDisplayedArea(left, top, width, height)
If GdViewer1.CopyRegionToClipboard(left, top, width, height) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "GdViewer.GetDisplayedArea")
Else
MessageBox.Show("The page content can't be copied. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
int left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);
if (GdViewer1.CopyRegionToClipboard(left, top, width, height) == GdPictureStatus.OK)
{
MessageBox.Show("Done!", "GdViewer.GetDisplayedArea");
}
else MessageBox.Show("The page content can't be copied. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea");
Example
The first example shows you how to determine the fully visible rectangle of the current page within the viewer.
The second example demonstrates how to copy the content of this visible area to the clipboard.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0
GdViewer1.GetDisplayedArea(left, top, width, height)
Dim leftDoc As Integer = GdViewer1.GetDocumentLeft()
Dim topDoc As Integer = GdViewer1.GetDocumentTop()
MessageBox.Show("Page width (X): " + GdViewer1.PageWidth + vbCrLf + "Page height (Y): " + GdViewer1.PageHeight + vbCrLf + vbCrLf +
"Document: top-left point (X,Y): " + leftDoc + ", " + topDoc + vbCrLf +
"Displayed area:" + vbCrLf + " top-left point (X,Y): " + left + ", " + top + vbCrLf + " width: " + width + " height: " + height, "GdViewer.GetDisplayedArea")
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
int left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);
int leftDoc = GdViewer1.GetDocumentLeft();
int topDoc = GdViewer1.GetDocumentTop();
MessageBox.Show("Page width (X): " + GdViewer1.PageWidth + "\nPage height (Y): " + GdViewer1.PageHeight + "\n\n" +
"Document: top-left point (X,Y): " + leftDoc + ", " + topDoc + "\n" +
"Displayed area:\n top-left point (X,Y): " + left + ", " + top + "\n width: " + width + " height: " + height, "GdViewer.GetDisplayedArea");
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0
GdViewer1.GetDisplayedArea(left, top, width, height)
If GdViewer1.CopyRegionToClipboard(left, top, width, height) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "GdViewer.GetDisplayedArea")
Else
MessageBox.Show("The page content can't be copied. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
int left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);
if (GdViewer1.CopyRegionToClipboard(left, top, width, height) == GdPictureStatus.OK)
{
MessageBox.Show("Done!", "GdViewer.GetDisplayedArea");
}
else MessageBox.Show("The page content can't be copied. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetDisplayedArea");
See Also