Skip to main content
.NET Framework 4.5.2+

PdfGraphics.DrawPath(Pen, GraphicsPath) Method

Draws the specified path on a page.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void DrawPath(
    Pen pen,
    GraphicsPath path
)

Parameters

Name Type Description
pen Pen

A Pen object that specifies the color, width, and style of 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 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 (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, 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 Pen(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