Skip to main content
All docs
V26.1
  • GraphicsPath Class

    A sequence of connected lines and curves that can be filled or outlined.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public class GraphicsPath :
        ICloneable

    The following members return GraphicsPath objects:

    Example

    How to: Add Path Fragments to a Page

    The following code snippet adds a triangle and Bezier curve to the page:

    PDF page showing a gray filled triangle with black outline and a red filled bezier curve with black outline

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument())
    {
        var page = pdfDocument.Pages.Add(DXPaperKind.A4);
    
        // Create a triangle path.
        GraphicsPath triangle = new GraphicsPath(new PointF(410, 490));
        triangle.AppendLineSegment(new PointF(480, 460));
        triangle.AppendLineSegment(new PointF(550, 490));
        triangle.Closed = true;
    
        PathFragment triangleFragment = new PathFragment() {
    
            Paths = { triangle },
            Outline = Outline.Create(Fill.CreateSolid(PdfColor.Black)),
            Fill = Fill.CreateSolid(PdfColor.FromRgb(211, 211, 211)),
            Action = PathShapeAction.FillAndStroke 
        };            
    
        page.AddFragment(triangleFragment);
    
        // Create a Bezier curve path.
        GraphicsPath bezier = new GraphicsPath(new PointF(210, 375));
        bezier.AppendBezierSegment(new PointF(210, 320),
            new PointF(350, 320), new PointF(350, 375));
        bezier.AppendBezierSegment(new PointF(350, 430),
            new PointF(210, 430), new PointF(210, 375));
    
        PathFragment bezierFragment = new PathFragment()
        {
            Paths = { bezier },
            Outline = Outline.Create(Fill.CreateSolid(PdfColor.Black)),
            Fill = Fill.CreateSolid(PdfColor.Red),
            Action = PathShapeAction.FillAndStroke
        };
    
        page.AddFragment(bezierFragment);
    
        pdfDocument.Save(new FileStream("Result.pdf", FileMode.Create, FileAccess.Write));
    }
    

    Implements

    Inheritance

    Object
    GraphicsPath
    See Also