Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfGraphics.FillPath(Brush, GraphicsPath) Method

Fills the interior of the specified path.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v24.2.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing

#Declaration

public void FillPath(
    Brush brush,
    GraphicsPath path
)

#Parameters

Name Type Description
brush Brush

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

path GraphicsPath

A GraphicsPath 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 (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 SolidBrush(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