Class PdfPolygon
Represents a set of points connected with lines, could be drawn and filled.
Inheritance
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfPolygon : PdfFillElement
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(50, 50);
PointF point2 = new PointF(100, 50);
PointF point3 = new PointF(150, 100);
PointF point4 = new PointF(150, 150);
PointF point5 = new PointF(100, 200);
PointF point6 = new PointF(50, 200);
PointF point7 = new PointF(0, 150);
PointF point8 = new PointF(0, 100);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(points);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(50, 50)
Dim point2 As New PointF(100, 50)
Dim point3 As New PointF(150, 100)
Dim point4 As New PointF(150, 150)
Dim point5 As New PointF(100, 200)
Dim point6 As New PointF(50, 200)
Dim point7 As New PointF(0, 150)
Dim point8 As New PointF(0, 100)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(points)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Constructors
PdfPolygon()
Initializes a new instance of the PdfPolygon class.
Declaration
protected PdfPolygon()
PdfPolygon(PdfBrush, PointF[])
Initializes a new instance of the PdfPolygon class.
Declaration
public PdfPolygon(PdfBrush brush, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | The brush of the polygon shape. |
System.Drawing.PointF[] | points | The points that represents the vertices of the polygon. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfBrushes.Red, points);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfBrushes.Red, points)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPolygon(PdfPen, PdfBrush, PointF[])
Initializes a new instance of the PdfPolygon class.
Declaration
public PdfPolygon(PdfPen pen, PdfBrush brush, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | The pen of the polygon shape. |
PdfBrush | brush | The brush of the polygon shape. |
System.Drawing.PointF[] | points | The points that represents the vertices of the polygon. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfPens.Black, PdfBrushes.Red, points);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfPens.Black, PdfBrushes.Red, points)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPolygon(PdfPen, PointF[])
Initializes a new instance of the PdfPolygon class.
Declaration
public PdfPolygon(PdfPen pen, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | The pen of the polygon shape. |
System.Drawing.PointF[] | points | The points that represents the vertices of the polygon. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfPens.Red, points);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfPens.Red, points)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPolygon(PointF[])
Initializes a new instance of the PdfPolygon class.
Declaration
public PdfPolygon(PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.PointF[] | points | The points that represents the vertices of the polygon. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(50, 50);
PointF point2 = new PointF(100, 50);
PointF point3 = new PointF(150, 100);
PointF point4 = new PointF(150, 150);
PointF point5 = new PointF(100, 200);
PointF point6 = new PointF(50, 200);
PointF point7 = new PointF(0, 150);
PointF point8 = new PointF(0, 100);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(points);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(50, 50)
Dim point2 As New PointF(100, 50)
Dim point3 As New PointF(150, 100)
Dim point4 As New PointF(150, 150)
Dim point5 As New PointF(100, 200)
Dim point6 As New PointF(50, 200)
Dim point7 As New PointF(0, 150)
Dim point8 As New PointF(0, 100)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(points)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Properties
Count
Gets a number of the points in the polygon.
Declaration
public int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfPens.Red, points);
//Get the polygon points count.
int count = polygon.Count;
Console.WriteLine("Polygon points count: " + count);
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfPens.Red, points)
'Get the polygon points count.
Dim count As Integer = polygon.Count
Console.WriteLine("Polygon points count: " + count)
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Points
Gets or sets the points of the polygon.
Declaration
public PointF[] Points { get; set; }
Property Value
Type |
---|
System.Drawing.PointF[] |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfPens.Black, new PointF[] { new PointF(0,100) });
//Set the polygon points.
polygon.Points = points;
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfPens.Black, New PointF() {New PointF(0, 100)})
'Set the polygon points.
polygon.Points = points
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Methods
AddPoint(PointF)
Adds a point to the polygon.
Declaration
public void AddPoint(PointF point)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.PointF | point | The last point of the polygon. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Polygon points.
PointF point1 = new PointF(100, 100);
PointF point2 = new PointF(150, 100);
PointF point3 = new PointF(200, 150);
PointF point4 = new PointF(200, 200);
PointF point5 = new PointF(150, 250);
PointF point6 = new PointF(100, 250);
PointF point7 = new PointF(50, 200);
PointF point8 = new PointF(50, 150);
PointF[] points = { point1, point2, point3, point4, point5, point6, point7, point8 };
//Create a new PDF polygon instance.
PdfPolygon polygon = new PdfPolygon(PdfPens.Red, points);
//Add points.
polygon.AddPoint(new PointF(50, 50));
//Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Polygon points.
Dim point1 As New PointF(100, 100)
Dim point2 As New PointF(150, 100)
Dim point3 As New PointF(200, 150)
Dim point4 As New PointF(200, 200)
Dim point5 As New PointF(150, 250)
Dim point6 As New PointF(100, 250)
Dim point7 As New PointF(50, 200)
Dim point8 As New PointF(50, 150)
Dim points As PointF() = {point1, point2, point3, point4, point5, point6, point7, point8}
'Create a new PDF polygon instance.
Dim polygon As New PdfPolygon(PdfPens.Red, points)
'Add points.
polygon.AddPoint(New PointF(50, 50))
'Draw the polygon to PDF page.
polygon.Draw(page, PointF.Empty)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)