Table of Contents

Class PdfPageLayerCollection

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

The class provides methods and properties to handle the collections of PdfPageLayer

public class PdfPageLayerCollection : PdfCollection, IEnumerable
Inheritance
PdfPageLayerCollection
Implements
Inherited Members

Examples

//Create PDF document.
 PdfDocument document = new PdfDocument();
 PdfPage page = document.Pages.Add();
 //Add the first layer.
 PdfPageLayer layer = page.Layers.Add("Layer1");
 PdfGraphics graphics = layer.Graphics;
 graphics.TranslateTransform(100, 60);
 //Draw arc.
 PdfPen pen = new PdfPen(System.Drawing.Color.Red, 50);
 RectangleF bounds = new RectangleF(0, 0, 50, 50);
 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);
 //Save the document.
 document.Save("Sample.pdf");
 //Close the document
 document.Close(true);
'Create PDF document.
Dim document As New PdfDocument()
Dim page As PdfPage = document.Pages.Add()
'Add the first layer.
Dim layer As PdfPageLayer = page.Layers.Add("Layer1")
Dim graphics As PdfGraphics = layer.Graphics
graphics.TranslateTransform(100, 60)
'Draw arc.
Dim pen As New PdfPen(System.Drawing.Color.Red, 50)
Dim bounds As New RectangleF(0, 0, 50, 50)
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)
'Save the document.
document.Save("Sample.pdf")
'Close the document
document.Close(True)

Constructors

PdfPageLayerCollection()

Initializes a new instance of the PdfPageLayerCollection class

public PdfPageLayerCollection()

PdfPageLayerCollection(PdfPageBase)

Initializes a new instance of the PdfPageLayerCollection class with PDF page

public PdfPageLayerCollection(PdfPageBase page)

Parameters

page PdfPageBase

Parent page for the layers in the collection.

Properties

this[int]

Gets or sets PdfPageLayer by its index from PdfPageLayerCollection

public PdfPageLayer this[int index] { get; set; }

Parameters

index int

Property Value

PdfPageLayer

Remarks

The layers belonging to the same page can be added to the collection only.

Methods

Add()

Creates a new PdfPageLayer and adds it to the end of the collection.

public PdfPageLayer Add()

Returns

PdfPageLayer

Created PdfPageLayer

Add(PdfPageLayer)

Adds PdfPageLayer to the collection.

public int Add(PdfPageLayer layer)

Parameters

layer PdfPageLayer

The PdfPageLayer object.

Returns

int

Remarks

The layers belonging to the same page can be added to the collection only.

Add(string)

Creates a new PdfPageLayer with name and adds it to the end of the collection.

public PdfPageLayer Add(string LayerName)

Parameters

LayerName string

Layer Name.

Returns

PdfPageLayer

Created PdfPageLayer.

Add(string, bool)

Creates a new PdfPageLayer with name and Boolean flag to set the visibility of layer, and adds it to the end of the collection.

public PdfPageLayer Add(string LayerName, bool Visible)

Parameters

LayerName string

Layer Name.

Visible bool

Layer Visibility.

Returns

PdfPageLayer

Created PdfPageLayer.

Clear()

Clears layers from the PdfPageLayerCollection.

public void Clear()

Contains(PdfPageLayer)

Checks whether collection contains PdfPageLayer.

public bool Contains(PdfPageLayer layer)

Parameters

layer PdfPageLayer

PdfPageLayer object.

Returns

bool

True - if collection contains layer, False otherwise.

IndexOf(PdfPageLayer)

Returns index of the PdfPageLayer in the collection if exists, -1 otherwise.

public int IndexOf(PdfPageLayer layer)

Parameters

layer PdfPageLayer

PdfPageLayer object.

Returns

int

Returns index of the layer in the collection if exists, -1 otherwise.

Insert(int, PdfPageLayer)

Inserts PdfPageLayer into the collection at specified index

public void Insert(int index, PdfPageLayer layer)

Parameters

index int

Index of the layer.

layer PdfPageLayer

PdfPageLayer object.

Remarks

The layers belonging to the same page can be added to the collection only.

Remove(PdfPageLayer)

Removes layer from the collection.

public void Remove(PdfPageLayer layer)

Parameters

layer PdfPageLayer

PdfPageLayer object.

Remove(string)

Removes PdfPageLayer from the collection by its name.

public void Remove(string name)

Parameters

name string

Name of the layer.

RemoveAt(int)

Removes layer by its index from collections

public void RemoveAt(int index)

Parameters

index int

Index of the layer.