Package com.itextpdf.kernel.pdf
Class PdfOutline
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfOutline
-
public class PdfOutline extends java.lang.ObjectDocument outline object See ISO-320001, 12.3.3 Document Outline.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<PdfOutline>childrenprivate PdfDictionarycontentprivate PdfDestinationdestinationstatic intFLAG_BOLDA flag for displaying the outline item’s text with bold font.static intFLAG_ITALICA flag for displaying the outline item’s text with italic font.private PdfOutlineparentprivate PdfDocumentpdfDocprivate java.lang.Stringtitle
-
Constructor Summary
Constructors Constructor Description PdfOutline(PdfDocument doc)This constructor creates root outline in the document.PdfOutline(java.lang.String title, PdfDictionary content, PdfDocument pdfDocument)Create instance of document outline.PdfOutline(java.lang.String title, PdfDictionary content, PdfOutline parent)Create instance of document outline.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAction(PdfAction action)AddsPdfActionfor the outline,Akey.voidaddDestination(PdfDestination destination)AddsPdfDestinationfor the outline,Destkey.PdfOutlineaddOutline(PdfOutline outline)Adds anPdfOutlineas a child to existingPdfOutlineand put it to the end of the existingPdfOutlinechildren list.PdfOutlineaddOutline(java.lang.String title)Adds anPdfOutlineas a child to existingPdfOutlineand put it in the end of the existingPdfOutlinechildren list.PdfOutlineaddOutline(java.lang.String title, int position)Adds a newPdfOutlinewith specified parameters as a child to existingPdfOutlineand put it to specified position in the existingPdfOutlinechildren list.(package private) voidclear()Clear list of children.java.util.List<PdfOutline>getAllChildren()Gets list of children outlines.ColorgetColor()Gets color for the outline entry's text,Ckey.PdfDictionarygetContent()Gets content dictionary.PdfDestinationgetDestination()GetsPdfDestination.private PdfDictionarygetOutlineRoot()Gets the Outline root inpdfDoc's catalog entryPdfOutlinegetParent()Gets parent outline.java.lang.IntegergetStyle()Gets text style for the outline entry's text,Fkey.java.lang.StringgetTitle()Gets title of the outline.booleanisOpen()Defines if the outline is open or closed.private booleanisOutlineRoot()Determines if the currentPdfOutlineobject is the Outline Root.voidremoveOutline()Remove this outline from the document.voidsetColor(Color color)Sets color for the outline entry’s text,Ckey.(package private) voidsetDestination(PdfDestination destination)SetsPdfDestination.voidsetOpen(boolean open)Defines if the outline needs to be closed or not.voidsetStyle(int style)Sets text style for the outline entry’s text,Fkey.voidsetTitle(java.lang.String title)Sets title of the outline withPdfEncodings.UNICODE_BIGencoding,Titlekey.
-
-
-
Field Detail
-
FLAG_ITALIC
public static final int FLAG_ITALIC
A flag for displaying the outline item’s text with italic font.- See Also:
- Constant Field Values
-
FLAG_BOLD
public static final int FLAG_BOLD
A flag for displaying the outline item’s text with bold font.- See Also:
- Constant Field Values
-
children
private java.util.List<PdfOutline> children
-
title
private java.lang.String title
-
content
private PdfDictionary content
-
destination
private PdfDestination destination
-
parent
private PdfOutline parent
-
pdfDoc
private PdfDocument pdfDoc
-
-
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 dictionarypdfDocument-PdfDocumentthe 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 dictionaryparent- parent outline.addOutline(String, int)andaddOutline(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 withPdfEncodings.UNICODE_BIGencoding,Titlekey.- Parameters:
title- String value.
-
setColor
public void setColor(Color color)
Sets color for the outline entry’s text,Ckey.- Parameters:
color-Color
-
getColor
public Color getColor()
Gets color for the outline entry's text,Ckey.- Returns:
- color
Color.
-
setStyle
public void setStyle(int style)
Sets text style for the outline entry’s text,Fkey.- Parameters:
style- Could be eitherFLAG_BOLDorFLAG_ITALIC. Default value is0.
-
getStyle
public java.lang.Integer getStyle()
Gets text style for the outline entry's text,Fkey.- Returns:
- style value.
-
getContent
public PdfDictionary getContent()
Gets content dictionary.- Returns:
PdfDictionary.
-
getAllChildren
public java.util.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()
GetsPdfDestination.- Returns:
PdfDestination.
-
addDestination
public void addDestination(PdfDestination destination)
AddsPdfDestinationfor the outline,Destkey.- Parameters:
destination- instance ofPdfDestination.
-
addAction
public void addAction(PdfAction action)
AddsPdfActionfor the outline,Akey.- Parameters:
action- instance ofPdfAction.
-
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 newPdfOutlinewith specified parameters as a child to existingPdfOutlineand put it to specified position in the existingPdfOutlinechildren list.- Parameters:
title- an outline titleposition- 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 anPdfOutlineas a child to existingPdfOutlineand put it in the end of the existingPdfOutlinechildren list.- Parameters:
title- an outline title- Returns:
- just created outline
-
addOutline
public PdfOutline addOutline(PdfOutline outline)
Adds anPdfOutlineas a child to existingPdfOutlineand put it to the end of the existingPdfOutlinechildren 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)
SetsPdfDestination.- Parameters:
destination- instance ofPdfDestination.
-
getOutlineRoot
private PdfDictionary getOutlineRoot()
Gets the Outline root inpdfDoc's catalog entry- Returns:
- The
PdfDictionaryof the document's Outline root, ornullif it can't be found.
-
isOutlineRoot
private boolean isOutlineRoot()
Determines if the currentPdfOutlineobject is the Outline Root.- Returns:
falseif this is not the outline root or the root can not be found,trueotherwise.
-
-