Package com.itextpdf.kernel.pdf
Class PdfOutline
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfOutline
-
public class PdfOutline extends java.lang.Object
Document outline object See ISO-320001, 12.3.3 Document Outline.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<PdfOutline>
children
private PdfDictionary
content
private PdfDestination
destination
static int
FLAG_BOLD
A flag for displaying the outline item’s text with bold font.static int
FLAG_ITALIC
A flag for displaying the outline item’s text with italic font.private PdfOutline
parent
private PdfDocument
pdfDoc
private java.lang.String
title
-
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 void
addAction(PdfAction action)
AddsPdfAction
for the outline,A
key.void
addDestination(PdfDestination destination)
AddsPdfDestination
for the outline,Dest
key.PdfOutline
addOutline(PdfOutline outline)
Adds anPdfOutline
as a child to existingPdfOutline
and put it to the end of the existingPdfOutline
children list.PdfOutline
addOutline(java.lang.String title)
Adds anPdfOutline
as a child to existingPdfOutline
and put it in the end of the existingPdfOutline
children list.PdfOutline
addOutline(java.lang.String title, int position)
Adds a newPdfOutline
with specified parameters as a child to existingPdfOutline
and put it to specified position in the existingPdfOutline
children list.(package private) void
clear()
Clear list of children.java.util.List<PdfOutline>
getAllChildren()
Gets list of children outlines.Color
getColor()
Gets color for the outline entry's text,C
key.PdfDictionary
getContent()
Gets content dictionary.PdfDestination
getDestination()
GetsPdfDestination
.private PdfDictionary
getOutlineRoot()
Gets the Outline root inpdfDoc
's catalog entryPdfOutline
getParent()
Gets parent outline.java.lang.Integer
getStyle()
Gets text style for the outline entry's text,F
key.java.lang.String
getTitle()
Gets title of the outline.boolean
isOpen()
Defines if the outline is open or closed.private boolean
isOutlineRoot()
Determines if the currentPdfOutline
object is the Outline Root.void
removeOutline()
Remove this outline from the document.void
setColor(Color color)
Sets color for the outline entry’s text,C
key.(package private) void
setDestination(PdfDestination destination)
SetsPdfDestination
.void
setOpen(boolean open)
Defines if the outline needs to be closed or not.void
setStyle(int style)
Sets text style for the outline entry’s text,F
key.void
setTitle(java.lang.String title)
Sets title of the outline withPdfEncodings.UNICODE_BIG
encoding,Title
key.
-
-
-
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
-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 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_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 eitherFLAG_BOLD
orFLAG_ITALIC
. Default value is0
.
-
getStyle
public java.lang.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 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)
AddsPdfDestination
for the outline,Dest
key.- Parameters:
destination
- instance ofPdfDestination
.
-
addAction
public void addAction(PdfAction action)
AddsPdfAction
for the outline,A
key.- 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 newPdfOutline
with specified parameters as a child to existingPdfOutline
and put it to specified position in the existingPdfOutline
children 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 anPdfOutline
as a child to existingPdfOutline
and put it in the end of the existingPdfOutline
children list.- Parameters:
title
- an outline title- Returns:
- just created outline
-
addOutline
public PdfOutline addOutline(PdfOutline outline)
Adds anPdfOutline
as a child to existingPdfOutline
and put it to the end of the existingPdfOutline
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)
SetsPdfDestination
.- Parameters:
destination
- instance ofPdfDestination
.
-
getOutlineRoot
private PdfDictionary getOutlineRoot()
Gets the Outline root inpdfDoc
's catalog entry- Returns:
- The
PdfDictionary
of the document's Outline root, ornull
if it can't be found.
-
isOutlineRoot
private boolean isOutlineRoot()
Determines if the currentPdfOutline
object is the Outline Root.- Returns:
false
if this is not the outline root or the root can not be found,true
otherwise.
-
-