GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / DrawArc Method
The horizontal (X) coordinate of the center point of the angle, that makes the arc, 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 center point of the angle, that makes the arc, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The required radius of the circle, of which the arc is a part, expressed in the current units specified by the SetMeasurementUnit method.
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
Set this parameter to true, if you want to close the arc, otherwise set it to false.

Please note that if you fill the arc, it will be always drawn as closed, as it is shown in the example below.

Set this parameter to true, if you want to fill the arc 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 arc (draw a boundary line along the arc) 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
DrawArc Method (GdPicturePDF)
In This Topic
Draws a circular arc on the currently selected page of the loaded PDF document according to what you have specified. The center point of the angle, that makes the arc, and the radius of the circle, of which the arc is a part, 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 arc is clearly defined by the StartAngle and the EndAngle parameters.

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 DrawArc( _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Radius As Single, _
   ByVal StartAngle As Single, _
   ByVal EndAngle As Single, _
   ByVal Close As Boolean, _
   ByVal Fill As Boolean, _
   ByVal Stroke As Boolean _
) As GdPictureStatus
public GdPictureStatus DrawArc( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Close,
   bool Fill,
   bool Stroke
)
public function DrawArc( 
    Left: Single;
    Top: Single;
    Radius: Single;
    StartAngle: Single;
    EndAngle: Single;
    Close: Boolean;
    Fill: Boolean;
    Stroke: Boolean
): GdPictureStatus; 
public function DrawArc( 
   Left : float,
   Top : float,
   Radius : float,
   StartAngle : float,
   EndAngle : float,
   Close : boolean,
   Fill : boolean,
   Stroke : boolean
) : GdPictureStatus;
public: GdPictureStatus DrawArc( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Close,
   bool Fill,
   bool Stroke
) 
public:
GdPictureStatus DrawArc( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Close,
   bool Fill,
   bool Stroke
) 

Parameters

Left
The horizontal (X) coordinate of the center point of the angle, that makes the arc, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Top
The vertical (Y) coordinate of the center point of the angle, that makes the arc, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Radius
The required radius of the circle, of which the arc is a part, expressed in the current units specified by the SetMeasurementUnit method.
StartAngle
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
EndAngle
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
Close
Set this parameter to true, if you want to close the arc, otherwise set it to false.

Please note that if you fill the arc, it will be always drawn as closed, as it is shown in the example below.

Fill
Set this parameter to true, if you want to fill the arc 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 arc (draw a boundary line along the arc) 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 angles are measured clockwise using this method.

Example
How to draw stroked and filled arcs. The example shows you reasonable combinations of the Close, the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawArc"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    '//This is the font only used to describe the drawn arcs.
    Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the arcs
           (gdpicturePDF.SetLineWidth(0.1F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
           (gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the arcs
           (gdpicturePDF.DrawArc(5, 6, 4, -45, 45, False, False, True) = GdPictureStatus.OK) AndAlso 'the first arc
           (gdpicturePDF.DrawArc(15, 6, 4, -45, 45, False, True, True) = GdPictureStatus.OK) AndAlso 'the second arc
           (gdpicturePDF.DrawArc(5, 12, 4, -45, 45, True, False, True) = GdPictureStatus.OK) AndAlso 'the third arc
           (gdpicturePDF.DrawArc(15, 12, 4, -45, 45, True, True, True) = GdPictureStatus.OK) AndAlso 'the fourth arc
           (gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso 'the color used to draw text + the code below is used to describe all arcs drawn above
           (gdpicturePDF.DrawText(fontName, 5, 6, "1") = GdPictureStatus.OK) AndAlso 'starting point of the first arc
           (gdpicturePDF.DrawText(fontName, 15, 6, "2") = GdPictureStatus.OK) AndAlso 'starting point of the second arc
           (gdpicturePDF.DrawText(fontName, 5, 12, "3") = GdPictureStatus.OK) AndAlso 'starting point of the third arc
           (gdpicturePDF.DrawText(fontName, 15, 12, "4") = GdPictureStatus.OK) AndAlso 'starting point of the four arc
           (gdpicturePDF.DrawText(fontName, 3, 5, "only stroke") = GdPictureStatus.OK) AndAlso 'used attributes
           (gdpicturePDF.DrawText(fontName, 13, 5, "fill & stroke") = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontName, 3, 11, "close, not fill, but stroke") = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontName, 13, 11, "close & fill & stroke") = GdPictureStatus.OK) Then
            status = gdpicturePDF.SaveToFile("test_DrawArc.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 AddStandardFont() method has failed with the status: " + status.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: DrawArc";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    //This is the font only used to describe the drawn arcs.
    string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the arcs
            (gdpicturePDF.SetLineWidth(0.1f) == GdPictureStatus.OK) && //the line width used to stroke
            (gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the arcs
            (gdpicturePDF.DrawArc(5, 6, 4, -45, 45, false, false, true) == GdPictureStatus.OK) && //the first arc
            (gdpicturePDF.DrawArc(15, 6, 4, -45, 45, false, true, true) == GdPictureStatus.OK) && //the second arc
            (gdpicturePDF.DrawArc(5, 12, 4, -45, 45, true, false, true) == GdPictureStatus.OK) && //the third arc
            (gdpicturePDF.DrawArc(15, 12, 4, -45, 45, true, true, true) == GdPictureStatus.OK) && //the fourth arc
            //the code below is used to describe all arcs drawn above
            (gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) && //the color used to draw text
            (gdpicturePDF.DrawText(fontName, 5, 6, "1") == GdPictureStatus.OK) && //starting point of the first arc
            (gdpicturePDF.DrawText(fontName, 15, 6, "2") == GdPictureStatus.OK) && //starting point of the second arc
            (gdpicturePDF.DrawText(fontName, 5, 12, "3") == GdPictureStatus.OK) && //starting point of the third arc
            (gdpicturePDF.DrawText(fontName, 15, 12, "4") == GdPictureStatus.OK) && //starting point of the four arc
            (gdpicturePDF.DrawText(fontName, 3, 5, "only stroke") == GdPictureStatus.OK) && //used attributes
            (gdpicturePDF.DrawText(fontName, 13, 5, "fill & stroke") == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontName, 3, 11, "close, not fill, but stroke") == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontName, 13, 11, "close & fill & stroke") == GdPictureStatus.OK))
        {
            status = gdpicturePDF.SaveToFile("test_DrawArc.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 AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also