Skip to main content
All docs
V23.2

PdfGraphics.DrawPath(DXPen, DXGraphicsPath) Method

Draws the specified path on a page.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void DrawPath(
    DXPen pen,
    DXGraphicsPath path
)

Parameters

Name Type Description
pen DXPen

A DXPen object that specifies the color, width, and style of 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 DrawPath method allows you to draw paths that specify outlines of open and closed figures.

The current transformation matrix of the PdfGraphics object applies to the GraphicsPath object before the DrawPath method draws this path.

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 draws the specified path on a page.

Draw 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.
            DXGraphicsPath path = new DXGraphicsPath();
            PointF[] points = new PointF[] 
            { 
              new PointF(150, 150), 
              new PointF(70, 100), 
              new PointF(100, 300), 
              new PointF(300, 400), 
              new PointF(400, 700) 
            };
            path.AddClosedCurve(points);

            // Draw a path.
            using (var pen = new DXPen(Color.Red, 5))
                graphics.DrawPath(pen, path);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
See Also