modern-pdf-lib / PdfLayer
Class: PdfLayer
Defined in: src/layers/optionalContent.ts:37
Represents a single optional content group (layer) in a PDF.
Each layer has a name and a default visibility state. Content can be associated with a layer using the BDC/EMC marked-content operators in the content stream.
Constructors
Constructor
new PdfLayer(
name,visible?):PdfLayer
Defined in: src/layers/optionalContent.ts:42
Parameters
name
string
visible?
boolean = true
Returns
PdfLayer
Properties
name
readonlyname:string
Defined in: src/layers/optionalContent.ts:38
Methods
getName()
getName():
string
Defined in: src/layers/optionalContent.ts:58
Get the layer name.
Returns
string
getRef()
getRef():
PdfRef|undefined
Defined in: src/layers/optionalContent.ts:66
Get the indirect reference for this layer's OCG dictionary. Only available after toDict() has been called.
Returns
PdfRef | undefined
isVisible()
isVisible():
boolean
Defined in: src/layers/optionalContent.ts:48
Check whether this layer is visible by default.
Returns
boolean
setVisible()
setVisible(
visible):void
Defined in: src/layers/optionalContent.ts:53
Set the default visibility of this layer.
Parameters
visible
boolean
Returns
void
toDict()
toDict(
registry):PdfRef
Defined in: src/layers/optionalContent.ts:77
Serialize this layer as an OCG dictionary and register it in the object registry.
Parameters
registry
The PDF object registry.
Returns
The indirect reference to the OCG dictionary.
fromDict()
staticfromDict(dict):PdfLayer
Defined in: src/layers/optionalContent.ts:97
Parse a PdfLayer from an OCG dictionary.
Parameters
dict
The OCG dictionary.
Returns
PdfLayer
A PdfLayer instance.