PdfCollection Class
The class used to handle the collection of PDF objects.
Inheritance
System.Object
PdfCollection
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfCollection : IEnumerable
Examples
//Create new document.
PdfDocument document = new PdfDocument();
//Add new page.
PdfPage page = document.Pages.Add();
//Add the first layer.
PdfPageLayer layer = page.Layers.Add("Layer1");
//Get layer graphics.
PdfGraphics graphics = layer.Graphics;
graphics.TranslateTransform(100, 60);
//Create new instance of PDF pen.
PdfPen pen = new PdfPen(System.Drawing.Color.Red, 50);
RectangleF bounds = new RectangleF(0, 0, 50, 50);
//Draw arc.
graphics.DrawArc(pen, bounds, 360, 360);
//Add another layer on the page.
PdfPageLayer layer2 = page.Layers.Add("Layer2");
graphics = layer2.Graphics;
graphics.TranslateTransform(100, 180);
//Draw ellipse.
graphics.DrawEllipse(pen, bounds);
//Get layer collection from page.
PdfCollection collection = page.Layers;
//Get the total count of layers.
int count = collection.Count;
//Save and close the document.
document.Save("Output.pdf");
document.Close(true);
'Create new document.
Dim document As PdfDocument = New PdfDocument()
'Add new page.
Dim page As PdfPage = document.Pages.Add()
'Add the first layer.
Dim layer As PdfPageLayer = page.Layers.Add("Layer1")
'Get layer graphics.
Dim graphics As PdfGraphics = layer.Graphics
graphics.TranslateTransform(100, 60)
'Create new instance of PDF pen.
Dim pen As PdfPen = New PdfPen(System.Drawing.Color.Red, 50)
Dim bounds As RectangleF = New RectangleF(0, 0, 50, 50)
'Draw arc.
graphics.DrawArc(pen, bounds, 360, 360)
'Add another layer on the page.
Dim layer2 As PdfPageLayer = page.Layers.Add("Layer2")
graphics = layer2.Graphics
graphics.TranslateTransform(100, 180)
'Draw ellipse.
graphics.DrawEllipse(pen, bounds)
'Get layer collection from page.
Dim collection As PdfCollection = page.Layers
'Get the total count of layers.
Dim count As Integer = collection.Count
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)
Constructors
PdfCollection()
Initializes a new instance of the PdfCollection class.
Declaration
public PdfCollection()
Examples
//Create new document.
PdfDocument document = new PdfDocument();
//Add new page.
PdfPage page = document.Pages.Add();
//Add the first layer.
PdfPageLayer layer = page.Layers.Add("Layer1");
//Get layer graphics.
PdfGraphics graphics = layer.Graphics;
graphics.TranslateTransform(100, 60);
//Create new instance of PDF pen.
PdfPen pen = new PdfPen(System.Drawing.Color.Red, 50);
RectangleF bounds = new RectangleF(0, 0, 50, 50);
//Draw arc.
graphics.DrawArc(pen, bounds, 360, 360);
//Add another layer on the page.
PdfPageLayer layer2 = page.Layers.Add("Layer2");
graphics = layer2.Graphics;
graphics.TranslateTransform(100, 180);
//Draw ellipse.
graphics.DrawEllipse(pen, bounds);
//Initialize new instance of PDF collection.
PdfCollection collection = new PdfCollection();
//Get layer collection from the page.
collection = page.Layers;
//Get the total count of layers.
int count = collection.Count;
//Save and close the document.
document.Save("Output.pdf");
document.Close(true);
'Create new document.
Dim document As PdfDocument = New PdfDocument()
'Add new page.
Dim page As PdfPage = document.Pages.Add()
'Add the first layer.
Dim layer As PdfPageLayer = page.Layers.Add("Layer1")
'Get layer graphics.
Dim graphics As PdfGraphics = layer.Graphics
graphics.TranslateTransform(100, 60)
'Create new instance of PDF pen.
Dim pen As PdfPen = New PdfPen(System.Drawing.Color.Red, 50)
Dim bounds As RectangleF = New RectangleF(0, 0, 50, 50)
'Draw arc.
graphics.DrawArc(pen, bounds, 360, 360)
'Add another layer on the page.
Dim layer2 As PdfPageLayer = page.Layers.Add("Layer2")
graphics = layer2.Graphics
graphics.TranslateTransform(100, 180)
'Draw ellipse.
graphics.DrawEllipse(pen, bounds)
'Initialize new instance of PDF collection.
Dim collection As PdfCollection = New PdfCollection()
'Get layer collection from the page.
collection = page.Layers
'Get the total count of layers.
Dim count As Integer = collection.Count
'Get the total count of layers.
Dim count As Integer = collection.Count
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)
See Also
Properties
Count
Gets number of the elements in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The total number of elements in the collection. |
Examples
//Create new document.
PdfDocument document = new PdfDocument();
//Add new page.
PdfPage page = document.Pages.Add();
//Add the first layer.
PdfPageLayer layer = page.Layers.Add("Layer1");
//Get layer graphics.
PdfGraphics graphics = layer.Graphics;
graphics.TranslateTransform(100, 60);
//Create new instance of PDF pen.
PdfPen pen = new PdfPen(System.Drawing.Color.Red, 50);
RectangleF bounds = new RectangleF(0, 0, 50, 50);
//Draw arc.
graphics.DrawArc(pen, bounds, 360, 360);
//Add another layer on the page.
PdfPageLayer layer2 = page.Layers.Add("Layer2");
graphics = layer2.Graphics;
graphics.TranslateTransform(100, 180);
//Draw ellipse.
graphics.DrawEllipse(pen, bounds);
//Get layer collection from page.
PdfCollection collection = page.Layers;
//Get the total count of layers.
int count = collection.Count;
//Save and close the document.
document.Save("Output.pdf");
document.Close(true);
'Create new document.
Dim document As PdfDocument = New PdfDocument()
'Add new page.
Dim page As PdfPage = document.Pages.Add()
'Add the first layer.
Dim layer As PdfPageLayer = page.Layers.Add("Layer1")
'Get layer graphics.
Dim graphics As PdfGraphics = layer.Graphics
graphics.TranslateTransform(100, 60)
'Create new instance of PDF pen.
Dim pen As PdfPen = New PdfPen(System.Drawing.Color.Red, 50)
Dim bounds As RectangleF = New RectangleF(0, 0, 50, 50)
'Draw arc.
graphics.DrawArc(pen, bounds, 360, 360)
'Add another layer on the page.
Dim layer2 As PdfPageLayer = page.Layers.Add("Layer2")
graphics = layer2.Graphics
graphics.TranslateTransform(100, 180)
'Draw ellipse.
graphics.DrawEllipse(pen, bounds)
'Get layer collection from page.
Dim collection As PdfCollection = page.Layers
'Get the total count of layers.
Dim count As Integer = collection.Count
'Save and close the document.
document.Save("Output.pdf")
document.Close(True)
See Also
List
Gets internal list of the collection.
Declaration
protected List<object> List { get; }
Property Value
Type |
---|
System.Collections.Generic.List<System.Object> |
Methods
GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | Returns an enumerator that iterates through a collection. |
Implements
System.Collections.IEnumerable