Class PdfLayer
java.lang.Object
com.itextpdf.text.pdf.PdfObject
com.itextpdf.text.pdf.PdfDictionary
com.itextpdf.text.pdf.PdfLayer
- All Implemented Interfaces:
PdfOCG, Serializable
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanHolds value of property on.private booleanHolds value of property onPanel.protected PdfLayerprotected PdfIndirectReferenceprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a child layer.static PdfLayercreateTitle(String title, PdfWriter writer) Creates a title 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 panelvoidsetCreatorInfo(String creator, String subtype) Used by the creating application to store application-specific data associated with this optional content group.voidsetExport(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).voidsetLanguage(String lang, boolean preferred) Specifies the language of the content controlled by this optional content groupvoidSets 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.voidsetPageElement(String pe) Indicates that the group contains a pagination artifact.voidSpecifies that the content in this group is intended for use in printing(package private) voidSets thePdfIndirectReferencethat represents this layer.voidOne of more users for whom this optional content group is primarily intended.voidsetView(boolean view) Indicates that the group should be set to that state when the document is opened in a viewer application.voidsetZoom(float min, float max) Specifies a range of magnifications at which the content in this optional content group is best viewed.Methods inherited from class PdfDictionary
checkType, clear, contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsStream, getAsString, getDirectObject, getKeys, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, putEx, remove, size, toPdf, toStringMethods inherited from class PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, 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) -
PdfLayer
Creates a new layer.- Parameters:
name- the name of the layerwriter- the writer- Throws:
IOException
-
-
Method Details
-
createTitle
-
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
-
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
-
setCreatorInfo
Used by the creating application to store application-specific data associated with this optional content group.- Parameters:
creator- a text string specifying the application that created the groupsubtype- a string defining the type of content controlled by the group. Suggested values include but are not limited to Artwork, for graphic-design or publishing applications, and Technical, for technical designs such as building plans or schematics
-
setLanguage
Specifies the language of the content controlled by this optional content group- Parameters:
lang- a language string which specifies a language and possibly a locale (for example, es-MX represents Mexican Spanish)preferred- used by viewer applications when there is a partial match but no exact match between the system language and the language strings in all usage dictionaries
-
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
-
setZoom
public void setZoom(float min, float max) Specifies a range of magnifications at which the content in this optional content group is best viewed.- Parameters:
min- the minimum recommended magnification factors at which the group should be ON. A negative value will set the default to 0max- the maximum recommended magnification factor at which the group should be ON. A negative value will set the largest possible magnification supported by the viewer application
-
setPrint
Specifies that the content in this group is intended for use in printing- Parameters:
subtype- a name specifying the kind of content controlled by the group; for example, Trapping, PrintersMarks and Watermarkprintstate- indicates that the group should be set to that state when the document is printed from a viewer application
-
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
-
setPageElement
Indicates that the group contains a pagination artifact.- Parameters:
pe- one of the following names: "HF" (Header Footer), "FG" (Foreground), "BG" (Background), or "L" (Logo).- Since:
- 5.0.2
-
setUser
-
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
-