Skip to main content

PdfGraphics.DrawPolygon(Pen, PointF[]) Method

Draws a polygon by points from the specified array.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing


public void DrawPolygon(
    Pen pen,
    PointF[] points


Name Type Description
pen Pen

A Pen object that specifies the color, width, and style of the polygon.

points PointF[]

An array of PointF structures that specify the polygon vertices (in world coordinate system).


The first two points of the points array specify the first polygon side. Each next side connects the previous side’s end point and the next array point. If the first and last array points are different, they specify the last polygon side. Pass the points and pen parameters to the DrawPolygon method to draw a polygon.

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.
Draws content on a new page.

The code sample below draws a polygon by seven points.

Draw a Polygon

using DevExpress.Pdf;
using System.Drawing;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        using (PdfGraphics graphics = processor.CreateGraphics())
            // Create a point array.
            PointF[] points = new PointF[] 
                new PointF(50, 50), 
                new PointF(200, 10), 
                new PointF(450, 150), 
                new PointF(500, 200), 
                new PointF(520, 350), 
                new PointF(570, 650), 
                new PointF(500, 700) 

            // Draw a polygon.
            using (var pen = new Pen(Color.Red, 5))
                graphics.DrawPolygon(pen, points);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);
See Also