Click or drag to resize
Pdf Library for .NET

PdfLayer Class

A layer of a PDF document (optional content): content a viewer can show or hide, as in Acrobat's Layers panel. Obtained from Layers.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfLayer

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public class PdfLayer

The PdfLayer type exposes the following members.

Properties
 NameDescription
Public propertyLayersGets the layers nested under this one in a viewer's layer list.
Public propertyLockedGets or sets whether a viewer lets the reader show or hide the layer (locked: it does not).
Public propertyNameGets or sets the name of the layer, as a viewer lists it.
Public propertyPrintStateGets or sets when the content of the layer is printed. PrintWhenVisible by default.
Public propertyVisibleGets or sets whether the layer is shown when the document is opened.
Top
Methods
 NameDescription
Public methodEqualsGets whether this object stands for the same layer of the same document.
(Overrides ObjectEquals(Object))
Public methodGetHashCodeReturns a hash code for the layer.
(Overrides ObjectGetHashCode)
Public methodToStringReturns the name of the layer.
(Overrides ObjectToString)
Top
Remarks

On a new document, layers are added with Add(String) and content is drawn in one with Layer - any element, an html or Word region included - or with Layer for everything a header, footer or stamp holds.

The layers of a loaded document can be listed, shown or hidden, locked, renamed, added, moved, removed (with or without what they draw) and flattened; page objects can be moved into a layer with Layer, and new elements drawn in one.

PDF/A-1 does not allow layers: adding one to such a document is refused.

Example
PdfDocument document = new PdfDocument();
PdfLayer draft = document.Layers.Add("Draft");
PdfLayer notes = document.Layers.Add("Review notes", false);   // hidden when the document opens
notes.PrintState = PdfLayerPrintState.NeverPrint;
PdfPage page = document.AddPage();
page.Add(new PdfTextElement(50, 50, "DRAFT", font) { Layer = draft });
page.Add(new PdfTextElement(50, 100, "Check the totals", font) { Layer = notes });
document.Save("out.pdf");
document.Close();
See Also