Back to Devexpress

PdfGraphics.FillPath(DXBrush, DXGraphicsPath) Method

officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-fillpath-x28-devexpress-dot-drawing-dot-dxbrush-devexpress-dot-drawing-dot-dxgraphicspath-x29.md

latest4.6 KB
Original Source

PdfGraphics.FillPath(DXBrush, DXGraphicsPath) Method

Fills the interior of the specified path.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Drawing

Declaration

csharp
public void FillPath(
    DXBrush brush,
    DXGraphicsPath path
)
vb
Public Sub FillPath(
    brush As DXBrush,
    path As DXGraphicsPath
)

Parameters

NameTypeDescription
brushDXBrush

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.AddToPageBackgroundThese methods allow you to draw content on an existing page.PdfDocumentProcessor.RenderNewPageDraws content on a new page.

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

csharp
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.CreateGraphicsWorldSystem())
        {
            // 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);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
vb
Imports DevExpress.Pdf
Imports System.Drawing
Imports DevExpress.Drawing
'...

Using processor As New PdfDocumentProcessor()
    processor.CreateEmptyDocument()
    Dim page As PdfPage = processor.AddNewPage(PdfPaperSize.A4)
        Using graphics As PdfGraphics = processor.CreateGraphicsWorldSystem()
            ' Create a path.
            Dim path As New GraphicsPath()
            Dim points() As 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 brush = New DXSolidBrush(Color.Blue)
                graphics.FillPath(brush, path)
            End Using

            ' Add graphics content to the document page.
            graphics.AddToPageForeground(page)
        End Using
    processor.SaveDocument("out2.pdf")
End Using
Process.Start("out.pdf")

See Also

PdfGraphics Class

PdfGraphics Members

DevExpress.Pdf Namespace