Package com.itextpdf.text
Class ListItem
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<Element>
-
- com.itextpdf.text.Phrase
-
- com.itextpdf.text.Paragraph
-
- com.itextpdf.text.ListItem
-
- All Implemented Interfaces:
Indentable
,Spaceable
,Element
,IAccessibleElement
,TextElementArray
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<Element>
,java.util.Collection<Element>
,java.util.List<Element>
,java.util.RandomAccess
public class ListItem extends Paragraph
AListItem
is aParagraph
that can be added to aList
.Example 1:
The result of this code looks like this:List list = new List(true, 20); list.add(new ListItem("First line")); list.add(new ListItem("The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?")); list.add(new ListItem("Third line"));
- First line
- The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?
- Third line
The result of this code looks like this:List overview = new List(false, 10); overview.add(new ListItem("This is an item")); overview.add("This is another item");
- This is an item
- This is another item
- See Also:
Element
,List
,Paragraph
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ListBody
listBody
private ListLabel
listLabel
private static long
serialVersionUID
protected Chunk
symbol
this is the symbol that will precede the listitem.-
Fields inherited from class com.itextpdf.text.Paragraph
accessibleAttributes, alignment, id, indentationLeft, indentationRight, keeptogether, paddingTop, role, spacingAfter, spacingBefore
-
Fields inherited from class com.itextpdf.text.Phrase
font, hyphenation, leading, multipliedLeading, tabSettings
-
Fields inherited from interface com.itextpdf.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, BODY, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CHAPTER, CHUNK, CREATIONDATE, CREATOR, DIV, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LANGUAGE, LIST, LISTITEM, MARKED, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK
-
-
Constructor Summary
Constructors Constructor Description ListItem()
Constructs aListItem
.ListItem(float leading)
Constructs aListItem
with a certain leading.ListItem(float leading, Chunk chunk)
Constructs aListItem
with a certainChunk
and a certain leading.ListItem(float leading, java.lang.String string)
Constructs aListItem
with a certainString
and a certain leading.ListItem(float leading, java.lang.String string, Font font)
Constructs aListItem
with a certain leading,String
andFont
.ListItem(Chunk chunk)
Constructs aListItem
with a certainChunk
.ListItem(Phrase phrase)
Constructs aListItem
with a certainPhrase
.ListItem(java.lang.String string)
Constructs aListItem
with a certainString
.ListItem(java.lang.String string, Font font)
Constructs aListItem
with a certainString
and a certainFont
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjustListSymbolFont()
Changes the font of the list symbol to the font of the first chunk in the list item.Paragraph
cloneShallow(boolean spacingBefore)
Creates a shallow clone of the Paragraph.ListBody
getListBody()
ListLabel
getListLabel()
Chunk
getListSymbol()
Returns the listsymbol.void
setIndentationLeft(float indentation, boolean autoindent)
Sets the indentation of this paragraph on the left side.void
setListSymbol(Chunk symbol)
Sets the listsymbol.int
type()
Gets the type of the text element.-
Methods inherited from class com.itextpdf.text.Paragraph
add, breakUp, getAccessibleAttribute, getAccessibleAttributes, getAlignment, getExtraParagraphSpace, getFirstLineIndent, getId, getIndentationLeft, getIndentationRight, getKeepTogether, getPaddingTop, getRole, getSpacingAfter, getSpacingBefore, isInline, populateProperties, setAccessibleAttribute, setAlignment, setExtraParagraphSpace, setFirstLineIndent, setId, setIndentationLeft, setIndentationRight, setKeepTogether, setPaddingTop, setRole, setSpacingAfter, setSpacingBefore, spacingAfter, spacingBefore
-
Methods inherited from class com.itextpdf.text.Phrase
add, add, addAll, addChunk, addSpecial, getChunks, getContent, getFont, getHyphenation, getInstance, getInstance, getInstance, getLeading, getMultipliedLeading, getTabSettings, getTotalLeading, hasLeading, isContent, isEmpty, isNestable, process, setFont, setHyphenation, setLeading, setLeading, setMultipliedLeading, setTabSettings, trim
-
Methods inherited from class java.util.ArrayList
addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
symbol
protected Chunk symbol
this is the symbol that will precede the listitem.- Since:
- 5.0 used to be private
-
listBody
private ListBody listBody
-
listLabel
private ListLabel listLabel
-
-
Constructor Detail
-
ListItem
public ListItem()
Constructs aListItem
.
-
ListItem
public ListItem(float leading)
Constructs aListItem
with a certain leading.- Parameters:
leading
- the leading
-
ListItem
public ListItem(Chunk chunk)
Constructs aListItem
with a certainChunk
.- Parameters:
chunk
- aChunk
-
ListItem
public ListItem(java.lang.String string)
Constructs aListItem
with a certainString
.- Parameters:
string
- aString
-
ListItem
public ListItem(java.lang.String string, Font font)
Constructs aListItem
with a certainString
and a certainFont
.- Parameters:
string
- aString
font
- aString
-
ListItem
public ListItem(float leading, Chunk chunk)
Constructs aListItem
with a certainChunk
and a certain leading.- Parameters:
leading
- the leadingchunk
- aChunk
-
ListItem
public ListItem(float leading, java.lang.String string)
Constructs aListItem
with a certainString
and a certain leading.- Parameters:
leading
- the leadingstring
- aString
-
ListItem
public ListItem(float leading, java.lang.String string, Font font)
Constructs aListItem
with a certain leading,String
andFont
.- Parameters:
leading
- the leadingstring
- aString
font
- aFont
-
ListItem
public ListItem(Phrase phrase)
Constructs aListItem
with a certainPhrase
.- Parameters:
phrase
- aPhrase
-
-
Method Detail
-
type
public int type()
Gets the type of the text element.
-
cloneShallow
public Paragraph cloneShallow(boolean spacingBefore)
Description copied from class:Paragraph
Creates a shallow clone of the Paragraph.- Overrides:
cloneShallow
in classParagraph
- Returns:
-
setListSymbol
public void setListSymbol(Chunk symbol)
Sets the listsymbol.- Parameters:
symbol
- aChunk
-
setIndentationLeft
public void setIndentationLeft(float indentation, boolean autoindent)
Sets the indentation of this paragraph on the left side.- Parameters:
indentation
- the new indentationautoindent
- if set to true, indentation is done automagically, the given indentation float is disregarded.
-
adjustListSymbolFont
public void adjustListSymbolFont()
Changes the font of the list symbol to the font of the first chunk in the list item.- Since:
- 5.0.6
-
getListSymbol
public Chunk getListSymbol()
Returns the listsymbol.- Returns:
- a
Chunk
-
getListBody
public ListBody getListBody()
-
getListLabel
public ListLabel getListLabel()
-
-