Class PdfOutline


  • public class PdfOutline
    extends java.lang.Object
    Document outline object See ISO-320001, 12.3.3 Document Outline.
    • Field Detail

      • FLAG_ITALIC

        public static int FLAG_ITALIC
        A flag for displaying the outline item’s text with italic font.
      • FLAG_BOLD

        public static int FLAG_BOLD
        A flag for displaying the outline item’s text with bold font.
      • children

        private java.util.List<PdfOutline> children
      • title

        private java.lang.String title
    • Constructor Detail

      • PdfOutline

        PdfOutline​(java.lang.String title,
                   PdfDictionary content,
                   PdfDocument pdfDocument)
        Create instance of document outline.
        Parameters:
        title - the text that shall be displayed on the screen for this item.
        content - Outline dictionary
        pdfDocument - PdfDocument the outline belongs to.
      • PdfOutline

        PdfOutline​(java.lang.String title,
                   PdfDictionary content,
                   PdfOutline parent)
        Create instance of document outline.
        Parameters:
        title - the text that shall be displayed on the screen for this item.
        content - Outline dictionary
        parent - parent outline. addOutline(String, int) and addOutline(String) instead.
      • PdfOutline

        PdfOutline​(PdfDocument doc)
        This constructor creates root outline in the document.
        Parameters:
        doc - PdfDocument
    • Method Detail

      • getTitle

        public java.lang.String getTitle()
        Gets title of the outline.
        Returns:
        String value.
      • setTitle

        public void setTitle​(java.lang.String title)
        Sets title of the outline with PdfEncodings.UNICODE_BIG encoding, Title key.
        Parameters:
        title - String value.
      • setColor

        public void setColor​(Color color)
        Sets color for the outline entry’s text, C key.
        Parameters:
        color - Color
      • getColor

        public Color getColor()
        Gets color for the outline entry's text, C key.
        Returns:
        color Color.
      • setStyle

        public void setStyle​(int style)
        Sets text style for the outline entry’s text, F key.
        Parameters:
        style - Could be either FLAG_BOLD or FLAG_ITALIC. Default value is 0.
      • getStyle

        public java.lang.Integer getStyle()
        Gets text style for the outline entry's text, F key.
        Returns:
        style value.
      • getAllChildren

        public java.util.List<PdfOutline> getAllChildren()
        Gets list of children outlines.
        Returns:
        List of PdfOutline.
      • addAction

        public void addAction​(PdfAction action)
        Adds PdfAction for the outline, A key.
        Parameters:
        action - instance of PdfAction.
      • setOpen

        public void setOpen​(boolean open)
        Defines if the outline needs to be closed or not. By default, outlines are open.
        Parameters:
        open - if false, the outline will be closed by default
      • isOpen

        public boolean isOpen()
        Defines if the outline is open or closed.
        Returns:
        true if open,false otherwise.
      • addOutline

        public PdfOutline addOutline​(java.lang.String title,
                                     int position)
        Adds a new PdfOutline with specified parameters as a child to existing PdfOutline and put it to specified position in the existing PdfOutline children list.
        Parameters:
        title - an outline title
        position - a position in the current outline child List where a new outline should be added. If the position equals -1, then the outline will be put in the end of children list.
        Returns:
        just created outline
      • addOutline

        public PdfOutline addOutline​(java.lang.String title)
        Adds an PdfOutline as a child to existing PdfOutline and put it in the end of the existing PdfOutline children list.
        Parameters:
        title - an outline title
        Returns:
        just created outline
      • addOutline

        public PdfOutline addOutline​(PdfOutline outline)
        Adds an PdfOutline as a child to existing PdfOutline and put it to the end of the existing PdfOutline children list.
        Parameters:
        outline - an outline to add.
        Returns:
        just created outline
      • removeOutline

        public void removeOutline()
        Remove this outline from the document. Outlines that are children of this outline are removed recursively
      • clear

        void clear()
        Clear list of children.
      • getOutlineRoot

        private PdfDictionary getOutlineRoot()
        Gets the Outline root in pdfDoc's catalog entry
        Returns:
        The PdfDictionary of the document's Outline root, or null if it can't be found.
      • isOutlineRoot

        private boolean isOutlineRoot()
        Determines if the current PdfOutline object is the Outline Root.
        Returns:
        false if this is not the outline root or the root can not be found, true otherwise.