Skip to main content
All docs
V25.1
  • PdfGraphics.FillPath(DXBrush, DXGraphicsPath) Method

    Fills the interior of the specified path.

    Namespace: DevExpress.Pdf

    Assembly: DevExpress.Pdf.v25.1.Drawing.dll

    NuGet Package: DevExpress.Pdf.Drawing

    Declaration

    public void FillPath(
        DXBrush brush,
        DXGraphicsPath path
    )

    Parameters

    Name Type Description
    brush DXBrush

    A DXBrush object that specifies the brush used to fill the path.

    path DXGraphicsPath

    A DXGraphicsPath object in world coordinate system.

    Remarks

    A path is a series of connected lines, curves, and geometric shape primitives. The FillPath method fills the path interior with a brush.

    If the path specifies an open figure (when starting and ending points are different), the FillPath method adds a line from the figure’s first point to its last point to close the figure.

    To draw a shape on the PDF page, use one of the following methods:

    PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackground
    These methods allow you to draw content on an existing page.
    PdfDocumentProcessor.RenderNewPage
    Draws content on a new page.

    The code sample below closes an open figure defined by a path and fills the path with the specified brush.

    Fill a Path

    using DevExpress.Pdf;
    using System.Drawing;
    using DevExpress.Drawing;
    //...
    
    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        processor.CreateEmptyDocument();
        PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
            using (PdfGraphics graphics = processor.CreateGraphics())
            {
                // Create a path.
                GraphicsPath path = new GraphicsPath();
                PointF[] points = new PointF[] 
                { 
                  new PointF(150, 750), 
                  new PointF(170, 300), 
                  new PointF(300, 50), 
                  new PointF(400, 100), 
                  new PointF(500, 70) 
                };
                path.AddCurve(points);
    
                // Fill a path.
                using (var brush = new DXSolidBrush(Color.Blue))
                    graphics.FillPath(brush, path);
    
                // Add graphics content to the document page.
                graphics.AddToPageForeground(page, 72, 72);
            }
        processor.SaveDocument("out2.pdf");
    }
    Process.Start("out.pdf");
    
    See Also