Class OptionalContentContext

java.lang.Object
com.datalogics.PDFL.OptionalContentContext

public class OptionalContentContext extends Object
Defines the context for optional content in a PDF. An Optional Content Context is a status object that defines the context for optional content within a document.

The context tracks the On/Off status for Optional Content Groups (layers) within a document. It contains flags that control whether to display content that is marked as optional.

  • Constructor Details

    • OptionalContentContext

      public OptionalContentContext(Document document)
      Creates a context object that represents an optional-content state of the document, using the current state as the initial state for each group (OCG), as determined by the document's optional-content configuration.

      Parameters:
      document - The document for which to create a context.
  • Method Details

    • delete

      public void delete()
    • equals

      public boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • getOCGStates

      public List<Boolean> getOCGStates(List<OptionalContentGroup> ocgs)
      Gets the ON-OFF states for the given optional-content groups (OCGs) in the given optional-content context.

      Parameters:
      ocgs - A list of optional-content groups whose states are obtained.
      Returns:
      An array of OCG states corresponding to the array of OCGs, true for ON and false for OFF.
    • setOCGStates

      public void setOCGStates(List<OptionalContentGroup> ocgs, List<Boolean> newStates)
      Sets the ON-OFF states for the given optional-content groups (OCGs) in the given optional-content context. The newStates vector must be large enough to hold as many Boolean values as there are OCGs.

      Parameters:
      ocgs - A list of optional-content groups.
      newStates - A list of new OCG states corresponding to the list of OCGs, true for ON and false for OFF. The list must contain as many states as there are non-NULL OCGs in the pdocgs list.
    • getStateOfOCG

      public boolean getStateOfOCG(OptionalContentGroup ocg)
      Gets the ON-OFF state for the given optional content group (OCG) in this optional content context.

      Parameters:
      ocg - The optional content group whose state will be retrieved.
    • setStateOfOCG

      public void setStateOfOCG(OptionalContentGroup ocg, boolean newValue)
      Sets the ON-OFF state for the given optional content group (OCG) in this optional content context.

      Parameters:
      ocg - The optional content group whose state will be set.
      newValue - The new ON-OFF state for the optional content group.
    • clone

      public OptionalContentContext clone()
      Makes a copy of the optional content context.

      Returns:
      A copy of the original optional content context.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDrawOptionalContent

      public OptionalContentDrawingPolicy getDrawOptionalContent()
      Gets the drawing policy for the optional content in this optional content context.

      Returns:
      The drawing policy for optional content in this optional content context.
    • setDrawOptionalContent

      public void setDrawOptionalContent(OptionalContentDrawingPolicy newPolicy)
      Sets the drawing policy for the optional content in this optional content context.

      Parameters:
      newPolicy - The new drawing policy for optional content in this optional content context.