officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-fillpolygon-x28-devexpress-dot-drawing-dot-dxbrush-system-dot-drawing-dot-pointf-x29.md
Fills the interior of a polygon specified by array points.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Drawing.dll
NuGet Package : DevExpress.Pdf.Drawing
public void FillPolygon(
DXBrush brush,
PointF[] points
)
Public Sub FillPolygon(
brush As DXBrush,
points As PointF()
)
| Name | Type | Description |
|---|---|---|
| brush | DXBrush |
A DXBrush object that specifies the brush used to fill the polygon.
| | points | PointF[] |
An array of PointF structures that specify the polygon vertices (in world coordinate system).
|
This method fills the polygon interior with a brush. The points parameter specifies the polygon vertices.
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 fills a polygon with the specified brush.
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 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)
};
// Fill a polygon.
using (var brush = new DXSolidBrush(Color.Blue))
graphics.FillPolygon(brush, points);
// Add graphics content to the document page.
graphics.AddToPageForeground(page);
}
processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
Imports DevExpress.Pdf
Imports System.Drawing
'...
Using processor As New PdfDocumentProcessor()
processor.CreateEmptyDocument()
Dim page As PdfPage = processor.AddNewPage(PdfPaperSize.A4)
Using graphics As PdfGraphics = processor.CreateGraphicsWorldSystem()
' Create a point array.
Dim points() As 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)
}
' Fill a polygon.
Using brush = New DXSolidBrush(Color.Blue)
graphics.FillPolygon(brush, points)
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