Package com.itextpdf.kernel.pdf.layer
Class PdfOCProperties
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.pdf.layer.PdfOCProperties
This class represents /OCProperties entry if pdf catalog and manages the layers of the pdf document.
To be able to be wrapped with this PdfObjectWrapper
the PdfObject
must be indirect.
-
Constructor Summary
ConstructorDescriptionPdfOCProperties
(PdfDictionary ocPropertiesDict) Creates a new PdfOCProperties instance by the dictionary it represents, the dictionary must be an indirect object.PdfOCProperties
(PdfDocument document) Creates a new PdfOCProperties instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOCGRadioGroup
(List<PdfLayer> group) Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm.Fills the underlying PdfDictionary object with the current layers and their settings.fillDictionary
(boolean removeNonDocumentOcgs) Fills the underlying PdfDictionary object with the current layers and their settings.void
flush()
protected PdfDocument
Gets thePdfDocument
that owns that OCProperties.Gets the list of all the layers currently registered in the OCProperties.protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.protected void
registerLayer
(PdfLayer layer) This method registers a new layer in the OCProperties.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfOCProperties
Creates a new PdfOCProperties instance.- Parameters:
-
document
- the document the optional content belongs to
-
PdfOCProperties
Creates a new PdfOCProperties instance by the dictionary it represents, the dictionary must be an indirect object.- Parameters:
-
ocPropertiesDict
- the dictionary of optional content properties, must have an indirect reference.
-
-
Method Details
-
addOCGRadioGroup
Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm. That is, the state of at most one optional content group in the array should be ON at a time: if one group is turned ON, all others must be turned OFF.- Parameters:
-
group
- the radio group
-
fillDictionary
Fills the underlying PdfDictionary object with the current layers and their settings. Note that it completely regenerates the dictionary, so your direct changes to the dictionary will not take any affect.- Returns:
- the resultant dictionary
-
fillDictionary
Fills the underlying PdfDictionary object with the current layers and their settings. Note that it completely regenerates the dictionary, so your direct changes to the dictionary will not take any affect.- Parameters:
-
removeNonDocumentOcgs
- the flag indicating whether it is necessary to delete OCGs not from the current document - Returns:
- the resultant dictionary
-
flush
public void flush()- Overrides:
-
flush
in classPdfObjectWrapper<PdfDictionary>
-
getLayers
Gets the list of all the layers currently registered in the OCProperties. Note that this is just a new list and modifications to it will not affect anything.- Returns:
-
list of all the
layers
currently registered in the OCProperties
-
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.
-
registerLayer
This method registers a new layer in the OCProperties.- Parameters:
-
layer
- the new layer - Throws:
-
IllegalArgumentException
- if layer param is null
-
getDocument
Gets thePdfDocument
that owns that OCProperties.- Returns:
-
the
PdfDocument
that owns that OCProperties
-