Class PdfLayer

  • All Implemented Interfaces:
    PdfOCG

    class PdfLayer
    extends PdfDictionary
    implements PdfOCG
    An optional content group is a dictionary representing a collection of graphics that can be made visible or invisible dynamically by users of viewer applications. In iText they are referenced as layers.
    • Field Detail

      • children

        private java.util.ArrayList children
      • title

        private final java.lang.String title
      • on

        private boolean on
        Holds value of property on.
      • onPanel

        private boolean onPanel
        Holds value of property onPanel.
    • Constructor Detail

      • PdfLayer

        PdfLayer​(java.lang.String title)
    • Method Detail

      • getTitle

        java.lang.String getTitle()
      • addChild

        void addChild​(PdfLayer child)
        Adds a child layer. Nested layers can only have one parent.
        Parameters:
        child - the child layer
      • getParent

        public PdfLayer getParent()
        Gets the parent layer.
        Returns:
        the parent layer or null if the layer has no parent
      • getChildren

        public java.util.ArrayList getChildren()
        Gets the children layers.
        Returns:
        the children layers or null if the layer has no children
      • getRef

        public PdfIndirectReference getRef()
        Gets the PdfIndirectReference that represents this layer.
        Specified by:
        getRef in interface PdfOCG
        Returns:
        the PdfIndirectReference that represents this layer
      • setRef

        void setRef​(PdfIndirectReference ref)
        Sets the PdfIndirectReference that represents this layer. This can only be done from PdfStamperImp.
        Parameters:
        ref - The reference to the OCG object
        Since:
        2.1.2
      • setName

        public void setName​(java.lang.String name)
        Sets the name of this layer.
        Parameters:
        name - the name of this layer
      • getPdfObject

        public PdfObject getPdfObject()
        Gets the dictionary representing the layer. It just returns this.
        Specified by:
        getPdfObject in interface PdfOCG
        Returns:
        the dictionary representing the layer
      • isOn

        public boolean isOn()
        Gets the initial visibility of the layer.
        Returns:
        the initial visibility of the layer
      • setOn

        public void setOn​(boolean on)
        Sets the initial visibility of the layer.
        Parameters:
        on - the initial visibility of the layer
      • setExport

        public void setExport​(boolean export)
        Specifies the recommended state for content in this group when the document (or part of it) is saved by a viewer application to a format that does not support optional content (for example, an earlier version of PDF or a raster image format).
        Parameters:
        export - the export state
      • setView

        public void setView​(boolean view)
        Indicates that the group should be set to that state when the document is opened in a viewer application.
        Parameters:
        view - the view state
      • isOnPanel

        public boolean isOnPanel()
        Gets the layer visibility in Acrobat's layer panel
        Returns:
        the layer visibility in Acrobat's layer panel
      • setOnPanel

        public void setOnPanel​(boolean onPanel)
        Sets the visibility of the layer in Acrobat's layer panel. If false the layer cannot be directly manipulated by the user. Note that any children layers will also be absent from the panel.
        Parameters:
        onPanel - the visibility of the layer in Acrobat's layer panel