Table of Contents

Class PdfCollection

Namespace
Syncfusion.Pdf
Assembly
Syncfusion.Pdf.Portable.dll

The class used to handle the collection of PDF objects.

public class PdfCollection : IEnumerable
Inheritance
PdfCollection
Implements
Derived
Inherited Members

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.

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.

public int Count { get; }

Property Value

int

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.

protected List<object> List { get; }

Property Value

List<object>
See Also

Methods

GetEnumerator()

Returns an enumerator that iterates through a collection.

public IEnumerator GetEnumerator()

Returns

IEnumerator

Returns an enumerator that iterates through a collection.

See Also

See Also