PdfGraphics.DrawPolygon(Pen, PointF[]) Method
Draws a polygon by points from the specified array.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
pen | Pen | A Pen object that specifies the color, width, and style of the polygon. |
points | Point |
An array of Point |
#Remarks
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.
- PdfDocumentProcessor.RenderNewPage
- Draws content on a new page.
The code sample below draws a polygon by seven points.
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 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);
}
processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");