Pdf | |
The PdfLayer type exposes the following members.
| Name | Description | |
|---|---|---|
| Layers | Gets the layers nested under this one in a viewer's layer list. | |
| Locked | Gets or sets whether a viewer lets the reader show or hide the layer (locked: it does not). | |
| Name | Gets or sets the name of the layer, as a viewer lists it. | |
| PrintState | Gets or sets when the content of the layer is printed. PrintWhenVisible by default. | |
| Visible | Gets or sets whether the layer is shown when the document is opened. |
| Name | Description | |
|---|---|---|
| Equals | Gets whether this object stands for the same layer of the same document. (Overrides ObjectEquals(Object)) | |
| GetHashCode | Returns a hash code for the layer. (Overrides ObjectGetHashCode) | |
| ToString | Returns the name of the layer. (Overrides ObjectToString) |
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.
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();