CoordDocumentToViewer Method (GdViewer)
In This Topic
Translates the coordinates of the point located in the document area of the document currently displayed in the GdViewer control
(the document space), in pixels, to the coordinates of the corresponding point located in the GdViewer control area (the viewer space), in pixels.
That said, the point with the coordinates (DocumentLeft, DocumentTop) inside the currently displayed page of the document matches
to the point with coordinates (ViewerLeft, ViewerTop) inside the GdViewer control area.
Syntax
'Declaration
Public Sub CoordDocumentToViewer( _
ByVal As Integer, _
ByVal As Integer, _
ByRef As Integer, _
ByRef As Integer _
)
public void CoordDocumentToViewer(
int ,
int ,
ref int ,
ref int
)
public procedure CoordDocumentToViewer(
: Integer;
: Integer;
var : Integer;
var : Integer
);
public function CoordDocumentToViewer(
: int,
: int,
: int,
: int
);
public: void CoordDocumentToViewer(
int ,
int ,
ref int ,
ref int
)
public:
void CoordDocumentToViewer(
int ,
int ,
int% ,
int%
)
Parameters
- DocumentLeft
- The horizontal (X) coordinate, in pixels, of the point located inside the document area.
- DocumentTop
- The vertical (Y) coordinate, in pixels, of the point located inside the document area.
- ViewerLeft
- Output parameter.The horizontal (X) coordinate, in pixels, of the corresponding point located inside the viewer area.
- ViewerTop
- Output parameter.The vertical (Y) coordinate, in pixels, of the corresponding point located inside the viewer area.
Example
How to draw a rectangle of selection around the text found.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
GdViewer1.RemoveAllRegions()
Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If text_found Then
'The first region surely exists.
Dim regID As Integer = GdViewer1.GetRegionID(1)
GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID))
Dim DocumentLeft As Integer = GdViewer1.GetRegionLeftPixels(regID)
Dim DocumentTop As Integer = GdViewer1.GetRegionTopPixels(regID)
Dim ViewerLeft As Integer = 0, ViewerTop As Integer = 0
GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ViewerLeft, ViewerTop)
Dim ViewerWidth As Integer = GdViewer1.GetRegionWidthPixels(regID)
Dim ViewerHeight As Integer = GdViewer1.GetRegionHeightPixels(regID)
GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight)
Else
MessageBox.Show("The given text has not been found.", "GdViewer.CoordDocumentToViewer")
End If
Else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.RemoveAllRegions();
bool text_found = GdViewer1.SearchText(text_to_find, 0, true);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (text_found)
{
//The first region surely exists.
int regID = GdViewer1.GetRegionID(1);
GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID));
int DocumentLeft = GdViewer1.GetRegionLeftPixels(regID);
int DocumentTop = GdViewer1.GetRegionTopPixels(regID);
int ViewerLeft = 0, ViewerTop = 0;
GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ref ViewerLeft, ref ViewerTop);
int ViewerWidth = GdViewer1.GetRegionWidthPixels(regID);
int ViewerHeight = GdViewer1.GetRegionHeightPixels(regID);
GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight);
}
else
MessageBox.Show("The given text has not been found.", "GdViewer.CoordDocumentToViewer");
}
else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer");
Example
How to draw a rectangle of selection around the text found.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
GdViewer1.RemoveAllRegions()
Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If text_found Then
'The first region surely exists.
Dim regID As Integer = GdViewer1.GetRegionID(1)
GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID))
Dim DocumentLeft As Integer = GdViewer1.GetRegionLeftPixels(regID)
Dim DocumentTop As Integer = GdViewer1.GetRegionTopPixels(regID)
Dim ViewerLeft As Integer = 0, ViewerTop As Integer = 0
GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ViewerLeft, ViewerTop)
Dim ViewerWidth As Integer = GdViewer1.GetRegionWidthPixels(regID)
Dim ViewerHeight As Integer = GdViewer1.GetRegionHeightPixels(regID)
GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight)
Else
MessageBox.Show("The given text has not been found.", "GdViewer.CoordDocumentToViewer")
End If
Else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.RemoveAllRegions();
bool text_found = GdViewer1.SearchText(text_to_find, 0, true);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (text_found)
{
//The first region surely exists.
int regID = GdViewer1.GetRegionID(1);
GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID));
int DocumentLeft = GdViewer1.GetRegionLeftPixels(regID);
int DocumentTop = GdViewer1.GetRegionTopPixels(regID);
int ViewerLeft = 0, ViewerTop = 0;
GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ref ViewerLeft, ref ViewerTop);
int ViewerWidth = GdViewer1.GetRegionWidthPixels(regID);
int ViewerHeight = GdViewer1.GetRegionHeightPixels(regID);
GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight);
}
else
MessageBox.Show("The given text has not been found.", "GdViewer.CoordDocumentToViewer");
}
else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CoordDocumentToViewer");
See Also