Class PdfLayer
java.lang.Object
com.aowagie.text.pdf.PdfObject
com.aowagie.text.pdf.PdfDictionary
com.aowagie.text.pdf.PdfLayer
- All Implemented Interfaces:
PdfOCG
An optional content group is a dictionary representing a collection of graphics
that can be made visible or invisible dynamically by users of viewer applications.
In iText they are referenced as layers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArrayListprivate booleanHolds value of property on.private booleanHolds value of property onPanel.private PdfLayerprivate PdfIndirectReferenceprivate final StringFields inherited from class PdfDictionary
CATALOG, hashMap, OUTLINES, PAGEFields inherited from class PdfObject
ARRAY, BOOLEAN, bytes, DICTIONARY, INDIRECT, NAME, NOTHING, NULL, NUMBER, STREAM, STRING, TEXT_PDFDOCENCODING, TEXT_UNICODE, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidAdds a child layer.Gets the children layers.Gets the parent layer.Gets the dictionary representing the layer.getRef()Gets thePdfIndirectReferencethat represents this layer.(package private) StringgetTitle()private PdfDictionarygetUsage()booleanisOn()Gets the initial visibility of the layer.booleanGets the layer visibility in Acrobat's layer panelvoidsetExport(boolean export) Specifies the recommended state for content in this group when the document (or part of it) is saved by a viewer application to a format that does not support optional content (for example, an earlier version of PDF or a raster image format).voidSets the name of this layer.voidsetOn(boolean on) Sets the initial visibility of the layer.voidsetOnPanel(boolean onPanel) Sets the visibility of the layer in Acrobat's layer panel.(package private) voidSets thePdfIndirectReferencethat represents this layer.voidsetView(boolean view) Indicates that the group should be set to that state when the document is opened in a viewer application.Methods inherited from class PdfDictionary
contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsString, getDirectObject, getKeys, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, remove, size, toPdf, toStringMethods inherited from class PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, setContent, setIndRef, type
-
Field Details
-
ref
-
children
-
parent
-
title
-
on
private boolean onHolds value of property on. -
onPanel
private boolean onPanelHolds value of property onPanel.
-
-
Constructor Details
-
PdfLayer
PdfLayer(String title)
-
-
Method Details
-
getTitle
String getTitle() -
addChild
Adds a child layer. Nested layers can only have one parent.- Parameters:
child- the child layer
-
getParent
Gets the parent layer.- Returns:
- the parent layer or
nullif the layer has no parent
-
getChildren
Gets the children layers.- Returns:
- the children layers or
nullif the layer has no children
-
getRef
Gets thePdfIndirectReferencethat represents this layer. -
setRef
Sets thePdfIndirectReferencethat represents this layer. This can only be done from PdfStamperImp.- Parameters:
ref- The reference to the OCG object- Since:
- 2.1.2
-
setName
Sets the name of this layer.- Parameters:
name- the name of this layer
-
getPdfObject
Gets the dictionary representing the layer. It just returnsthis.- Specified by:
getPdfObjectin interfacePdfOCG- Returns:
- the dictionary representing the layer
-
isOn
public boolean isOn()Gets the initial visibility of the layer.- Returns:
- the initial visibility of the layer
-
setOn
public void setOn(boolean on) Sets the initial visibility of the layer.- Parameters:
on- the initial visibility of the layer
-
getUsage
-
setExport
public void setExport(boolean export) Specifies the recommended state for content in this group when the document (or part of it) is saved by a viewer application to a format that does not support optional content (for example, an earlier version of PDF or a raster image format).- Parameters:
export- the export state
-
setView
public void setView(boolean view) Indicates that the group should be set to that state when the document is opened in a viewer application.- Parameters:
view- the view state
-
isOnPanel
public boolean isOnPanel()Gets the layer visibility in Acrobat's layer panel- Returns:
- the layer visibility in Acrobat's layer panel
-
setOnPanel
public void setOnPanel(boolean onPanel) Sets the visibility of the layer in Acrobat's layer panel. Iffalsethe layer cannot be directly manipulated by the user. Note that any children layers will also be absent from the panel.- Parameters:
onPanel- the visibility of the layer in Acrobat's layer panel
-