How can I help you?
PdfLayer
21 Apr 20263 minutes to read
Represents the base class for layer objects.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the collection of layers in the document
let layers: PdfLayerCollection = document.layers;
// Retrieve the first layer from the layers collection
let layer: PdfLayer = layers.at(0);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
Get layers PdfLayerCollection
Gets the collection of PdfLayer from the layer.
Get locked boolean
Gets the boolean indicating whether the layer is locked or not.
Set locked void
Sets the boolean indicating whether the layer is locked or not.
| Parameter | Type | Description |
|---|---|---|
| isLocked | boolean |
Boolean indicating whether the layer is locked or not. |
Get name string
Gets the name of the layer.
Set name void
Sets the name of the layer.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Name of the layer. |
Get printState PdfPrintState
Gets the print state of the layer.
Set printState void
Sets the print state of the layer.
| Parameter | Type | Description |
|---|---|---|
| printState | PdfPrintState |
Print state. |
Get visible boolean
Gets the visibility of the layer.
Set visible void
Sets the visibility of the layer.
| Parameter | Type | Description |
|---|---|---|
| isVisible | boolean |
Boolean indicating whether the specified layer is visible or not. |
Methods
createGraphics
Initializes graphics context of the layer.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the collection of layers in the document
let layers: PdfLayerCollection = document.layers;
// Add a new layer to the document with the name 'Layer1'
let layer: PdfLayer = layers.add('Layer1');
// Create graphics for the newly added layer on the specified page
let graphics: PdfGraphics = layer.createGraphics(page);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| page | PdfPage |
The PDF page. |
Returns PdfGraphics