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
PdfPageBaseParent 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
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
PdfPageLayerThe PdfPageLayer object.
Returns
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
stringLayer 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
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
PdfPageLayerPdfPageLayer 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
PdfPageLayerPdfPageLayer 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
intIndex of the layer.
layer
PdfPageLayerPdfPageLayer 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
PdfPageLayerPdfPageLayer object.
Remove(string)
Removes PdfPageLayer from the collection by its name.
public void Remove(string name)
Parameters
name
stringName of the layer.
RemoveAt(int)
Removes layer by its index from collections
public void RemoveAt(int index)
Parameters
index
intIndex of the layer.