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
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 this
To be able to be wrapped with this
PdfObjectWrapper the PdfObject must be indirect.
-
Constructor Summary
ConstructorsConstructorDescriptionPdfLayerMembership(PdfDictionary membershipDictionary) Creates a new PdfLayerMembership instance by its PdfDictionary, which must be an indirect object.Creates a new, empty membership layer. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new layer to the current layer membership.protected PdfDocumentGets thePdfDocumentthat owns that layer membership.Gets thePdfIndirectReferencethat represents this layer.Gets the collection of the layers this layer membership operates with.Gets the visibility expression for content belonging to this optional content membership dictionary.Gets the visibility policy for content belonging to this optional content membership dictionary.protected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.voidsetVisibilityExpression(PdfVisibilityExpression visibilityExpression) Sets the visibility expression for content belonging to this membership dictionary.voidsetVisibilityPolicy(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, unsetForbidReleaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.itextpdf.kernel.pdf.layer.IPdfOCG
getPdfObject
-
Constructor Details
-
PdfLayerMembership
Creates a new, empty membership layer.- Parameters:
-
doc- aPdfDocumentwhere a new empty membership layer creates
-
PdfLayerMembership
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 Details
-
getLayers
Gets the collection of the layers this layer membership operates with.- Returns:
-
list of
layersthis layer membership operates with
-
addLayer
Adds a new layer to the current layer membership.- Parameters:
-
layer- the layer to be added
-
setVisibilityPolicy
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
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
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
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
Description copied from interface:IPdfOCGGets thePdfIndirectReferencethat represents this layer.- Specified by:
-
getIndirectReferencein interfaceIPdfOCG - Returns:
-
the
PdfIndirectReferencethat represents this layer
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapperDefines 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:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
getDocument
Gets thePdfDocumentthat owns that layer membership.- Returns:
-
the
PdfDocumentthat owns that layer membership
-