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.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / AddEllipseToPath Method

AddEllipseToPath Method (GdPicturePDF)

In This Topic
Appends an ellipse, using the sequence of cubic Bézier curves, to the currently constructed path, defined within a currently selected page of the loaded PDF document. Be aware of your currently defined graphics state parameters, that subsequent filling and stroking operations applied onto the constructed path put into effect.

The ellipse is clearly defined by the center and the dimensions of its bounding box. All these coordinates 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. You can use the GdPicturePDF.GetMeasurementUnit method to determine the currently defined units and you can use the GdPicturePDF.SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration

 

Public Function AddEllipseToPath( _

   ByVal CenterX As Single, _

   ByVal CenterY As Single, _

   ByVal Width As Single, _

   ByVal Height As Single _

) As GdPictureStatus
public GdPictureStatus AddEllipseToPath( 

   float CenterX,

   float CenterY,

   float Width,

   float Height

)
public function AddEllipseToPath( 

    CenterX: Single;

    CenterY: Single;

    Width: Single;

    Height: Single

): GdPictureStatus; 
public function AddEllipseToPath( 

   CenterX : float,

   CenterY : float,

   Width : float,

   Height : float

) : GdPictureStatus;
public: GdPictureStatus AddEllipseToPath( 

   float CenterX,

   float CenterY,

   float Width,

   float Height

) 
public:

GdPictureStatus AddEllipseToPath( 

   float CenterX,

   float CenterY,

   float Width,

   float Height

) 

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.

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.

It is recommended to set the origin's location to be the upper left corner simply by using the GdPicturePDF.SetOrigin method to draw an expected shape of an ellipse, for further explanation please see the first example below.

For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide, as well as the Path Construction and Painting section in the PDF Reference.

Example
How to add an ellipse to the currently constructed path.
The first example shows you how the location of the document's origin affects the resulting shape of the drawn ellipse.
Dim caption As String = "Example: AddEllipseToPath"

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.SetFillColor(255, 192, 203) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then

    MessageBox.Show("Painting the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

    GoTo [error]

End If

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)

If (gdpicturePDF.SetFillColor(238, 130, 238) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then

    MessageBox.Show("Painting the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

    GoTo [error]

End If

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight)

If (gdpicturePDF.SetFillColor(255, 0, 0) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then

    MessageBox.Show("Painting the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

    GoTo [error]

End If

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight)

If (gdpicturePDF.SetFillColor(0, 0, 255) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse

   (gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then

    MessageBox.Show("Painting the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

    GoTo [error]

End If

Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_AddEllipseToPath1.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: AddEllipseToPath";

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.SetFillColor(255, 192, 203) != GdPictureStatus.OK) ||

    (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||

    (gdpicturePDF.FillPath() != GdPictureStatus.OK))

{

    MessageBox.Show("Painting the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    goto error;

}

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);

if ((gdpicturePDF.SetFillColor(238, 130, 238) != GdPictureStatus.OK) ||

    (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||

    (gdpicturePDF.FillPath() != GdPictureStatus.OK))

{

    MessageBox.Show("Painting the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    goto error;

}

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight);

if ((gdpicturePDF.SetFillColor(255, 0, 0) != GdPictureStatus.OK) ||

    (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||

    (gdpicturePDF.FillPath() != GdPictureStatus.OK))

{

    MessageBox.Show("Painting the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    goto error;

}

gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight);

if ((gdpicturePDF.SetFillColor(0, 0, 255) != GdPictureStatus.OK) ||

    (gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||

    (gdpicturePDF.FillPath() != GdPictureStatus.OK))

{

    MessageBox.Show("Painting the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    goto error;

}

GdPictureStatus status = gdpicturePDF.SaveToFile("test_AddEllipseToPath1.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();
The second example shows you how to draw only a part of your image into a clipping path defined by the shape of an ellipse.
Dim caption As String = "Example: AddEllipseToPath"

Dim gdpicturePDF As New GdPicturePDF()

If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso

   (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then

    Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")

    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

        Dim width As Single = gdpicturePDF.GetPageWidth()

        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

            Dim height As Single = gdpicturePDF.GetPageHeight()

            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

                'the new height of the destination area

                height = height / 2

                If (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.DrawImage(image_name, 0, height, width, height) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.DrawImage(image_name, 0, 0, width, height) = GdPictureStatus.OK) Then

                    Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_AddEllipseToPath2.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 GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

            End If

        Else

            MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

        End If

    Else

        MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

    End If

Else

    MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

End If

gdpicturePDF.Dispose()
string caption = "Example: AddEllipseToPath";

GdPicturePDF gdpicturePDF = new GdPicturePDF();

if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&

    (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))

{

    string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");

    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

    {

        float width = gdpicturePDF.GetPageWidth();

        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

        {

            float height = gdpicturePDF.GetPageHeight();

            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

            {

                //the new height of the destination area

                height = height / 2;

                if ((gdpicturePDF.SelectPage(1) == GdPictureStatus.OK) &&

                    (gdpicturePDF.DrawImage(image_name, 0, height, width, height) == GdPictureStatus.OK) &&

                    (gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) == GdPictureStatus.OK) &&

                    (gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&

                    (gdpicturePDF.DrawImage(image_name, 0, 0, width, height) == GdPictureStatus.OK))

                {

                    GdPictureStatus status = gdpicturePDF.SaveToFile("test_AddEllipseToPath2.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 GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

        }

        else

            MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    }

    else

        MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

}

else

    MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

gdpicturePDF.Dispose();
See Also