GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / DrawEllipse Method
The horizontal (X) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The width of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to fill the ellipse using the currently defined fill color, otherwise set it to false. You can set the fill color using the GdPicturePDF.SetFillColor method.
Set this parameter to true, if you want to stroke the ellipse (draw a boundary line along the rectangle) using the currently defined line color, otherwise set it to false. You can set the line color using the GdPicturePDF.SetLineColor method.
Example





In This Topic
DrawEllipse Method (GdPicturePDF)
In This Topic
Draws an ellipse on the currently selected page of the loaded PDF document according to what you have specified. The center of the ellipse and the dimensions of the ellipse's bounding box need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page. The ellipse is clearly defined by the center and the dimensions of its bounding box.

You can simply use the GdPicturePDF.GetMeasurementUnit method to determine the currently defined units and you can easily use the GdPicturePDF.SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Function DrawEllipse( _
   ByVal CenterX As Single, _
   ByVal CenterY As Single, _
   ByVal Width As Single, _
   ByVal Height As Single, _
   ByVal Fill As Boolean, _
   ByVal Stroke As Boolean _
) As GdPictureStatus
public GdPictureStatus DrawEllipse( 
   float CenterX,
   float CenterY,
   float Width,
   float Height,
   bool Fill,
   bool Stroke
)
public function DrawEllipse( 
    CenterX: Single;
    CenterY: Single;
    Width: Single;
    Height: Single;
    Fill: Boolean;
    Stroke: Boolean
): GdPictureStatus; 
public function DrawEllipse( 
   CenterX : float,
   CenterY : float,
   Width : float,
   Height : float,
   Fill : boolean,
   Stroke : boolean
) : GdPictureStatus;
public: GdPictureStatus DrawEllipse( 
   float CenterX,
   float CenterY,
   float Width,
   float Height,
   bool Fill,
   bool Stroke
) 
public:
GdPictureStatus DrawEllipse( 
   float CenterX,
   float CenterY,
   float Width,
   float Height,
   bool Fill,
   bool Stroke
) 

Parameters

CenterX
The horizontal (X) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
CenterY
The vertical (Y) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Width
The width of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Height
The height of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Fill
Set this parameter to true, if you want to fill the ellipse using the currently defined fill color, otherwise set it to false. You can set the fill color using the GdPicturePDF.SetFillColor method.
Stroke
Set this parameter to true, if you want to stroke the ellipse (draw a boundary line along the rectangle) using the currently defined line color, otherwise set it to false. You can set the line color using the GdPicturePDF.SetLineColor method.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Just to remind you that the center of the ellipse is the center of its bounding box.

Example
How to draw stroked and filled ellipses.
The first example shows you reasonable combinations of the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawEllipse"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the ellipses
       (gdpicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
       (gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the ellipses
       (gdpicturePDF.DrawEllipse(10, 15, 16, 24, False, True) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.DrawEllipse(10, 15, 12, 20, True, True) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.DrawEllipse(10, 15, 6, 12, True, False) = GdPictureStatus.OK) Then
        status = gdpicturePDF.SaveToFile("test_DrawEllipse1.pdf")
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
        Else
            MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawEllipse";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
        (gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the ellipses
        (gdpicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) && //the line width used to stroke
        (gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the ellipses
        (gdpicturePDF.DrawEllipse(10, 15, 16, 24, false, true) == GdPictureStatus.OK) &&
        (gdpicturePDF.DrawEllipse(10, 15, 12, 20, true, true) == GdPictureStatus.OK) &&
        (gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
        (gdpicturePDF.DrawEllipse(10, 15, 6, 12, true, false) == GdPictureStatus.OK))
    {
        status = gdpicturePDF.SaveToFile("test_DrawEllipse1.pdf");
        if (status == GdPictureStatus.OK)
            MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
        else
            MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
    }
    else
        MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
The second example shows you how the location of the document's origin affects drawing.
Dim caption As String = "Example: DrawEllipse"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() <> GdPictureStatus.OK Then
    MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
            
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
            
If gdpicturePDF.NewPage(210, 297) <> GdPictureStatus.OK Then
    MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
If (gdpicturePDF.SetFillAlpha(180) <> GdPictureStatus.OK) OrElse
   (gdpicturePDF.SetFillColor(255, 0, 0) <> GdPictureStatus.OK) OrElse
   (gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
    MessageBox.Show("Drawing the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
If (gdpicturePDF.SetFillColor(0, 0, 255) <> GdPictureStatus.OK) OrElse
   (gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
    MessageBox.Show("Drawing the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight)
If (gdpicturePDF.SetFillColor(138, 43, 226) <> GdPictureStatus.OK) OrElse
   (gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
    MessageBox.Show("Drawing the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight)
If (gdpicturePDF.SetFillColor(255, 228, 196) <> GdPictureStatus.OK) OrElse
   (gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
    MessageBox.Show("Drawing the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    GoTo [error]
End If
            
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_DrawEllipse2.pdf")
If status = GdPictureStatus.OK Then
    MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
    MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: DrawEllipse";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() != GdPictureStatus.OK)
{
    MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
            
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
            
if (gdpicturePDF.NewPage(210, 297) != GdPictureStatus.OK)
{
    MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
if ((gdpicturePDF.SetFillAlpha(180) != GdPictureStatus.OK) ||
    (gdpicturePDF.SetFillColor(255, 0, 0) != GdPictureStatus.OK) ||
    (gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
    MessageBox.Show("Drawing the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
if ((gdpicturePDF.SetFillColor(0, 0, 255) != GdPictureStatus.OK) ||
    (gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
    MessageBox.Show("Drawing the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight);
if ((gdpicturePDF.SetFillColor(138, 43, 226) != GdPictureStatus.OK) ||
    (gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
    MessageBox.Show("Drawing the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
            
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight);
if ((gdpicturePDF.SetFillColor(255, 228, 196) != GdPictureStatus.OK) ||
    (gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
    MessageBox.Show("Drawing the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    goto error;
}
            
GdPictureStatus status = gdpicturePDF.SaveToFile("test_DrawEllipse2.pdf");
if (status == GdPictureStatus.OK)
    MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
    MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
            
error:
gdpicturePDF.Dispose();
See Also