GetRectCoordinatesOnDocumentInch 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 inches, 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 GetRectCoordinatesOnDocumentInch( _
ByRef As Double, _
ByRef As Double, _
ByRef As Double, _
ByRef As Double _
)
public void GetRectCoordinatesOnDocumentInch(
ref double ,
ref double ,
ref double ,
ref double
)
public procedure GetRectCoordinatesOnDocumentInch(
var : Double;
var : Double;
var : Double;
var : Double
);
public function GetRectCoordinatesOnDocumentInch(
: double,
: double,
: double,
: double
);
public: void GetRectCoordinatesOnDocumentInch(
ref double ,
ref double ,
ref double ,
ref double
)
public:
void GetRectCoordinatesOnDocumentInch(
double% ,
double% ,
double% ,
double%
)
Parameters
- Left
- Output parameter. The horizontal (X) coordinate (0-based) of the top left point, in inches, 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 inches, of the rectangle of selection, related to the current page.
- Width
- Output parameter. The width, in inches, of the rectangle of selection.
- Height
- Output parameter. The height, in inches, of the rectangle of selection.
Example
How to draw a rectagle on the PDF document's page according to the rectangle drawn by a user within the viewer.
'We assume that the GdViewer1 control has been properly integrated.
'At the same let's assume that you have properly displayed a PDF document as well.
If GdViewer1.IsRect() Then
Dim filename As String = GdViewer1.GetLastPath()
Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
GdViewer1.GetRectCoordinatesOnDocumentInch(left, top, width, height)
Using oPDF As GdPicturePDF = New GdPicturePDF()
If oPDF.LoadFromFile(filename, True) = GdPictureStatus.OK Then
oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
oPDF.SetLineColor(255, 69, 0)
If oPDF.DrawRectangle(CSng(left), CSng(top), CSng(width), CSng(height), False, True) = GdPictureStatus.OK Then
If oPDF.SaveToFile(filename) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "GdViewer1.GetRectCoordinatesOnDocumentInch")
End If
End If
End If
oPDF.CloseDocument()
End Using
End If
//We assume that the GdViewer1 control has been properly integrated.
//At the same let's assume that you have properly displayed a PDF document as well.
if (GdViewer1.IsRect())
{
string filename = GdViewer1.GetLastPath();
double left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetRectCoordinatesOnDocumentInch(ref left, ref top, ref width, ref height);
using (GdPicturePDF oPDF = new GdPicturePDF())
{
if (oPDF.LoadFromFile(filename, true) == GdPictureStatus.OK)
{
oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
oPDF.SetLineColor(255, 69, 0);
if (oPDF.DrawRectangle((float)left, (float)top, (float)width, (float)height, false, true) == GdPictureStatus.OK)
{
if (oPDF.SaveToFile(filename) == GdPictureStatus.OK)
{
MessageBox.Show("Done!", "GdViewer1.GetRectCoordinatesOnDocumentInch");
}
}
}
oPDF.CloseDocument();
}
}
Example
How to draw a rectagle on the PDF document's page according to the rectangle drawn by a user within the viewer.
'We assume that the GdViewer1 control has been properly integrated.
'At the same let's assume that you have properly displayed a PDF document as well.
If GdViewer1.IsRect() Then
Dim filename As String = GdViewer1.GetLastPath()
Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
GdViewer1.GetRectCoordinatesOnDocumentInch(left, top, width, height)
Using oPDF As GdPicturePDF = New GdPicturePDF()
If oPDF.LoadFromFile(filename, True) = GdPictureStatus.OK Then
oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
oPDF.SetLineColor(255, 69, 0)
If oPDF.DrawRectangle(CSng(left), CSng(top), CSng(width), CSng(height), False, True) = GdPictureStatus.OK Then
If oPDF.SaveToFile(filename) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "GdViewer1.GetRectCoordinatesOnDocumentInch")
End If
End If
End If
oPDF.CloseDocument()
End Using
End If
//We assume that the GdViewer1 control has been properly integrated.
//At the same let's assume that you have properly displayed a PDF document as well.
if (GdViewer1.IsRect())
{
string filename = GdViewer1.GetLastPath();
double left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetRectCoordinatesOnDocumentInch(ref left, ref top, ref width, ref height);
using (GdPicturePDF oPDF = new GdPicturePDF())
{
if (oPDF.LoadFromFile(filename, true) == GdPictureStatus.OK)
{
oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
oPDF.SetLineColor(255, 69, 0);
if (oPDF.DrawRectangle((float)left, (float)top, (float)width, (float)height, false, true) == GdPictureStatus.OK)
{
if (oPDF.SaveToFile(filename) == GdPictureStatus.OK)
{
MessageBox.Show("Done!", "GdViewer1.GetRectCoordinatesOnDocumentInch");
}
}
}
oPDF.CloseDocument();
}
}
See Also