Class PdfOCProperties

java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.pdf.layer.PdfOCProperties

public class PdfOCProperties extends PdfObjectWrapper<PdfDictionary>
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 Details

    • PdfOCProperties

      public PdfOCProperties (PdfDocument document)
      Creates a new PdfOCProperties instance.
      Parameters:
      document - the document the optional content belongs to
    • PdfOCProperties

      public PdfOCProperties (PdfDictionary ocPropertiesDict)
      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

      public void 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. 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

      public PdfObject 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

      public PdfObject fillDictionary (boolean removeNonDocumentOcgs)
      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 class PdfObjectWrapper<PdfDictionary>
    • getLayers

      public List<PdfLayer> 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 class PdfObjectWrapper<PdfDictionary>
      Returns:
      true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
    • registerLayer

      protected void registerLayer (PdfLayer layer)
      This method registers a new layer in the OCProperties.
      Parameters:
      layer - the new layer
      Throws:
      IllegalArgumentException - if layer param is null
    • getDocument

      protected PdfDocument getDocument()
      Gets the PdfDocument that owns that OCProperties.
      Returns:
      the PdfDocument that owns that OCProperties