PdfLayerCollection
12 Sep 20256 minutes to read
The class provides methods and properties to handle the collection of PdfLayer.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the collection of layers in the document
let layers: PdfLayerCollection = document.layers;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
count number
Gets the layer count.
Methods
add
Create a new PdfLayer with name
add it to the end of the collection.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Name of the layer. |
Returns PdfLayer
add
Create a new PdfLayer with name and Boolean flag to set the visibility of layer
add it to the end of the collection.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Name of the layer. |
| visible | boolean |
Visibility of the layer. |
Returns PdfLayer
at
Gets the PdfLayer at the specified index.
| Parameter | Type | Description |
|---|---|---|
| index | number |
Layer index. |
Returns PdfLayer
clear
Remove all the layers.
Returns void
contains
Boolean indicating whether the specified layer exists or not.
| Parameter | Type | Description |
|---|---|---|
| layer | PdfLayer |
The layer to be checked. |
Returns boolean
contains
Boolean indicating whether the specified layer name exists or not.
| Parameter | Type | Description |
|---|---|---|
| name | string |
The layer name to be checked. |
Returns boolean
indexOf
Index of the specified layer.
| Parameter | Type | Description |
|---|---|---|
| layer | PdfLayer |
The layer to be checked. |
Returns number
move
Move the PdfLayer into the collection at specified index.
| Parameter | Type | Description |
|---|---|---|
| index | number |
Index of the layer. |
| layer | PdfLayer |
Layer to move. |
Returns void
remove
Remove the PdfLayer with layer instance from the collection.
| Parameter | Type | Description |
|---|---|---|
| layer | PdfLayer |
Layer to remove. |
Returns void
remove
Remove the PdfLayer with layer instance from the collection.
| Parameter | Type | Description |
|---|---|---|
| layer | PdfLayer |
Layer to remove. |
| removeGraphicalContent | boolean |
Remove graphical content, if true. |
Returns void
remove
Remove the PdfLayer at the layer name from the collection.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Layer name to remove. |
Returns void
remove
Remove the PdfLayer at the layer name from the collection.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Layer name to remove. |
| removeGraphicalContent | boolean |
Remove graphical content, if true. |
Returns void
removeAt
Remove the PdfLayer at the specified index from the collection.
| Parameter | Type | Description |
|---|---|---|
| index | number |
The index of the layer to be removed. |
Returns void
removeAt
Remove the PdfLayer at the specified index from the collection.
| Parameter | Type | Description |
|---|---|---|
| index | number |
The index of the layer to be removed. |
| removeGraphicalContent | boolean |
Remove graphical content, if true. |
Returns void