Class PdfPageLayerCollection
The class provides methods and properties to handle the collections of PdfPageLayer
Implements
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfPageLayerCollection : PdfCollection, IEnumerable
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
Declaration
public PdfPageLayerCollection()
PdfPageLayerCollection(PdfPageBase)
Initializes a new instance of the PdfPageLayerCollection class with PDF page
Declaration
public PdfPageLayerCollection(PdfPageBase page)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | Parent page for the layers in the collection. |
Properties
Item[Int32]
Gets or sets PdfPageLayer by its index from PdfPageLayerCollection
Declaration
public PdfPageLayer this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
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.
Declaration
public PdfPageLayer Add()
Returns
Type | Description |
---|---|
PdfPageLayer | Created PdfPageLayer |
Add(PdfPageLayer)
Adds PdfPageLayer to the collection.
Declaration
public int Add(PdfPageLayer layer)
Parameters
Type | Name | Description |
---|---|---|
PdfPageLayer | layer | The PdfPageLayer object. |
Returns
Type |
---|
System.Int32 |
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.
Declaration
public PdfPageLayer Add(string LayerName)
Parameters
Type | Name | Description |
---|---|---|
System.String | LayerName | Layer Name. |
Returns
Type | Description |
---|---|
PdfPageLayer | Created PdfPageLayer. |
Add(String, Boolean)
Creates a new PdfPageLayer with name and Boolean flag to set the visibility of layer, and adds it to the end of the collection.
Declaration
public PdfPageLayer Add(string LayerName, bool Visible)
Parameters
Type | Name | Description |
---|---|---|
System.String | LayerName | Layer Name. |
System.Boolean | Visible | Layer Visibility. |
Returns
Type | Description |
---|---|
PdfPageLayer | Created PdfPageLayer. |
Clear()
Clears layers from the PdfPageLayerCollection.
Declaration
public void Clear()
Contains(PdfPageLayer)
Checks whether collection contains PdfPageLayer.
Declaration
public bool Contains(PdfPageLayer layer)
Parameters
Type | Name | Description |
---|---|---|
PdfPageLayer | layer | PdfPageLayer object. |
Returns
Type | Description |
---|---|
System.Boolean | True - if collection contains layer, False otherwise. |
IndexOf(PdfPageLayer)
Returns index of the PdfPageLayer in the collection if exists, -1 otherwise.
Declaration
public int IndexOf(PdfPageLayer layer)
Parameters
Type | Name | Description |
---|---|---|
PdfPageLayer | layer | PdfPageLayer object. |
Returns
Type | Description |
---|---|
System.Int32 | Returns index of the layer in the collection if exists, -1 otherwise. |
Insert(Int32, PdfPageLayer)
Inserts PdfPageLayer into the collection at specified index
Declaration
public void Insert(int index, PdfPageLayer layer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the layer. |
PdfPageLayer | layer | PdfPageLayer object. |
Remarks
The layers belonging to the same page can be added to the collection only.
Remove(PdfPageLayer)
Removes layer from the collection.
Declaration
public void Remove(PdfPageLayer layer)
Parameters
Type | Name | Description |
---|---|---|
PdfPageLayer | layer | PdfPageLayer object. |
Remove(String)
Removes PdfPageLayer from the collection by its name.
Declaration
public void Remove(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the layer. |
RemoveAt(Int32)
Removes layer by its index from collections
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the layer. |