Class PdfPageLayer
The PdfPageLayer used to create layers in PDF document. Layers refers to sections of content in a PDF document that can be selectively viewed or hidden by document authors or consumers
Inheritance
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfPageLayer : Object, IPdfWrapper
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
PdfPageLayer(PdfPageBase)
Initializes a new instance of the PdfPageLayer class with specified PDF page.
Declaration
public PdfPageLayer(PdfPageBase page)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The PdfPageBase,parent page of the layer. |
Properties
Graphics
Gets Graphics context of the layer, used to draw various graphical content on layer.
Declaration
public PdfGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
PdfGraphics | The PdfGraphics used to draw various graphical content |
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)
Layers
Gets the collection of PdfPageLayer, this collection handle by the class PdfPageLayerCollection
Declaration
public PdfPageLayerCollection Layers { get; }
Property Value
Type | Description |
---|---|
PdfPageLayerCollection | The PdfPageLayerCollection used to handle collection of PdfPageLayer |
Name
Gets or sets the name of the layer
Declaration
public string Name { get; set; }
Property Value
Type |
---|
System.String |
Page
Gets parent page of the layer.
Declaration
public PdfPageBase Page { get; }
Property Value
Type |
---|
PdfPageBase |
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)
PrintState
Gets and sets printing state of the PDF page layer
Declaration
public PdfPrintState PrintState { get; set; }
Property Value
Type |
---|
PdfPrintState |
Visible
specifies whether visibility of the layer
Declaration
public bool Visible { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
Add()
Adds a new PDF Page layer.
Declaration
public PdfPageLayer Add()
Returns
Type | Description |
---|---|
PdfPageLayer | The PdfPageLayer |