A GraphicsPath object to be added to the current path.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / AddGraphicsToPath Method

AddGraphicsToPath Method (GdPicturePDF)

In This Topic
Appends a subpath, constructed from the specified GraphicsPath object, to a current path defined within a currently selected page of the loaded PDF document. The newly added subpath is built up using the path construction and path-painting operators.

All coordinates within the defined GraphicsPath object 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 simply use the GetMeasurementUnit method to determine the currently defined units and you can easily use the SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Function AddGraphicsToPath( _
   ByVal GraphicsPath As GraphicsPath _
) As GdPictureStatus
public GdPictureStatus AddGraphicsToPath( 
   GraphicsPath GraphicsPath
)
public function AddGraphicsToPath( 
    GraphicsPath: GraphicsPath
): GdPictureStatus; 
public function AddGraphicsToPath( 
   GraphicsPath : GraphicsPath
) : GdPictureStatus;
public: GdPictureStatus AddGraphicsToPath( 
   GraphicsPath* GraphicsPath
) 
public:
GdPictureStatus AddGraphicsToPath( 
   GraphicsPath^ GraphicsPath
) 

Parameters

GraphicsPath
A GraphicsPath object to be added to the current path.

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 SetOrigin method to draw an expected image, for further explanation please see the 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 convert and add a GraphicsPath object to the current path.
Dim caption As String = "Example: AddGraphicsToPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    Dim graphicsPath As New System.Drawing.Drawing2D.GraphicsPath()
    Dim myPoints As Point() = {New Point(50, 50), New Point(100, 100), New Point(50, 100), New Point(50, 50)}
    Dim myRect As New Rectangle(100, 100, 120, 120)
    graphicsPath.AddLines(myPoints)
    graphicsPath.AddRectangle(myRect)
    graphicsPath.AddEllipse(200, 200, 100, 100)
    graphicsPath.AddString("I Love GdPicture.NET", New FontFamily("Arial"), 0, 20, New Point(), New StringFormat())
    If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.SetLineColor(0, 0, 128) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.AddGraphicsToPath(graphicsPath) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.StrokePath() = GdPictureStatus.OK) Then
        status = gdpicturePDF.SaveToFile("test_AddGraphicsToPath.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
    graphicsPath.Dispose()
Else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddGraphicsToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
    Point[] myPoints = { new Point(50, 50), new Point(100, 100), new Point(50, 100), new Point(50, 50) };
    Rectangle myRect = new Rectangle(100, 100, 120, 120);
    graphicsPath.AddLines(myPoints);
    graphicsPath.AddRectangle(myRect);
    graphicsPath.AddEllipse(200, 200, 100, 100);
    graphicsPath.AddString("I Love GdPicture.NET", new FontFamily("Arial"), 0, 20, new Point(), new StringFormat());
            
    if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
        (gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
        (gdpicturePDF.SetLineColor(0, 0, 128) == GdPictureStatus.OK) &&
        (gdpicturePDF.AddGraphicsToPath(graphicsPath) == GdPictureStatus.OK) &&
        (gdpicturePDF.StrokePath() == GdPictureStatus.OK))
    {
        status = gdpicturePDF.SaveToFile("test_AddGraphicsToPath.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);
    }
    graphicsPath.Dispose();
}
else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also