Class PdfOutline

java.lang.Object
com.itextpdf.kernel.pdf.PdfOutline

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

  • Constructor Details

    • PdfOutline

      PdfOutline(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(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 Details

    • getTitle

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

      public void setTitle(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 Integer getStyle()
      Gets text style for the outline entry's text, F key.
      Returns:
      style value.
    • getContent

      public PdfDictionary getContent()
      Gets content dictionary.
      Returns:
      PdfDictionary.
    • getAllChildren

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

      public PdfOutline getParent()
      Gets parent outline.
      Returns:
      PdfOutline.
    • getDestination

      public PdfDestination getDestination()
      Returns:
      PdfDestination.
    • addDestination

      public void addDestination(PdfDestination destination)
      Adds PdfDestination for the outline, Dest key.
      Parameters:
      destination - instance of PdfDestination.
    • 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(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(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.
    • setDestination

      void setDestination(PdfDestination destination)
      Parameters:
      destination - instance of PdfDestination.
    • 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.