Package com.itextpdf.kernel.pdf.layer
Class PdfLayerMembership
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.layer.PdfLayerMembership
-
- All Implemented Interfaces:
IPdfOCG
public class PdfLayerMembership extends PdfObjectWrapper<PdfDictionary> implements IPdfOCG
Content typically belongs to a single optional content group, and is visible when the group is ON and invisible when it is OFF. To express more complex visibility policies, content should not declare itself to belong to an optional content group directly, but rather to an optional content membership dictionary represented by this class.
To be able to be wrapped with thisPdfObjectWrapper
thePdfObject
must be indirect.
-
-
Constructor Summary
Constructors Constructor Description PdfLayerMembership(PdfDictionary membershipDictionary)
Creates a new PdfLayerMembership instance by its PdfDictionary, which must be an indirect object.PdfLayerMembership(PdfDocument doc)
Creates a new, empty membership layer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLayer(PdfLayer layer)
Adds a new layer to the current layer membership.protected PdfDocument
getDocument()
Gets thePdfDocument
that owns that layer membership.PdfIndirectReference
getIndirectReference()
Gets thePdfIndirectReference
that represents this layer.java.util.Collection<PdfLayer>
getLayers()
Gets the collection of the layers this layer membership operates with.PdfVisibilityExpression
getVisibilityExpression()
Gets the visibility expression for content belonging to this optional content membership dictionary.PdfName
getVisibilityPolicy()
Gets the visibility policy for content belonging to this optional content membership dictionary.protected boolean
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.void
setVisibilityExpression(PdfVisibilityExpression visibilityExpression)
Sets the visibility expression for content belonging to this membership dictionary.void
setVisibilityPolicy(PdfName visibilityPolicy)
Sets the visibility policy for content belonging to this membership dictionary.-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.kernel.pdf.layer.IPdfOCG
getPdfObject
-
-
-
-
Constructor Detail
-
PdfLayerMembership
public PdfLayerMembership(PdfDocument doc)
Creates a new, empty membership layer.- Parameters:
doc
- aPdfDocument
where a new empty membership layer creates
-
PdfLayerMembership
public PdfLayerMembership(PdfDictionary membershipDictionary)
Creates a new PdfLayerMembership instance by its PdfDictionary, which must be an indirect object.- Parameters:
membershipDictionary
- the membership dictionary, must have an indirect reference.
-
-
Method Detail
-
getLayers
public java.util.Collection<PdfLayer> getLayers()
Gets the collection of the layers this layer membership operates with.- Returns:
- list of
layers
this layer membership operates with
-
addLayer
public void addLayer(PdfLayer layer)
Adds a new layer to the current layer membership.- Parameters:
layer
- the layer to be added
-
setVisibilityPolicy
public void setVisibilityPolicy(PdfName visibilityPolicy)
Sets the visibility policy for content belonging to this membership dictionary. Possible values are AllOn, AnyOn, AnyOff and AllOff. AllOn - Visible only if all of the entries are ON. AnyOn - Visible if any of the entries are ON. AnyOff - Visible if any of the entries are OFF. AllOff - Visible only if all of the entries are OFF. The default value is AnyOn.- Parameters:
visibilityPolicy
- the visibility policy
-
getVisibilityPolicy
public PdfName getVisibilityPolicy()
Gets the visibility policy for content belonging to this optional content membership dictionary.- Returns:
- the visibility policy for content belonging to this membership dictionary
-
setVisibilityExpression
public void setVisibilityExpression(PdfVisibilityExpression visibilityExpression)
Sets the visibility expression for content belonging to this membership dictionary.- Parameters:
visibilityExpression
- A (nested) array of which the first value is /And, /Or, or /Not followed by a series of indirect references to OCGs or other visibility expressions.
-
getVisibilityExpression
public PdfVisibilityExpression getVisibilityExpression()
Gets the visibility expression for content belonging to this optional content membership dictionary.- Returns:
- the visibility expression for content belonging to this membership dictionary, if not set return null
-
getIndirectReference
public PdfIndirectReference getIndirectReference()
Description copied from interface:IPdfOCG
Gets thePdfIndirectReference
that represents this layer.- Specified by:
getIndirectReference
in interfaceIPdfOCG
- Returns:
- the
PdfIndirectReference
that represents this layer
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
getDocument
protected PdfDocument getDocument()
Gets thePdfDocument
that owns that layer membership.- Returns:
- the
PdfDocument
that owns that layer membership
-
-