Package com.itextpdf.text
Class Paragraph
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<Element>
-
- com.itextpdf.text.Phrase
-
- com.itextpdf.text.Paragraph
-
- 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
- Direct Known Subclasses:
ListItem
public class Paragraph extends Phrase implements Indentable, Spaceable, IAccessibleElement
AParagraph
is a series ofChunk
s and/orPhrases
.A
Paragraph
has the same qualities of aPhrase
, but also some additional layout-parameters:- the indentation
- the alignment of the text
Paragraph p = new Paragraph("This is a paragraph", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));
- See Also:
Element
,Phrase
,ListItem
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<PdfName,PdfObject>
accessibleAttributes
protected int
alignment
The alignment of the text.private float
extraParagraphSpace
Holds value of property extraParagraphSpace.private float
firstLineIndent
Holds value of property firstLineIndent.protected AccessibleElementId
id
protected float
indentationLeft
The indentation of this paragraph on the left side.protected float
indentationRight
The indentation of this paragraph on the right side.protected boolean
keeptogether
Does the paragraph has to be kept together on 1 page.protected float
paddingTop
protected PdfName
role
private static long
serialVersionUID
protected float
spacingAfter
The spacing after the paragraph.protected float
spacingBefore
The spacing before the paragraph.-
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 Paragraph()
Constructs aParagraph
.Paragraph(float leading)
Constructs aParagraph
with a certain leading.Paragraph(float leading, Chunk chunk)
Constructs aParagraph
with a certainChunk
and a certain leading.Paragraph(float leading, java.lang.String string)
Constructs aParagraph
with a certainString
and a certain leading.Paragraph(float leading, java.lang.String string, Font font)
Constructs aParagraph
with a certain leading,String
andFont
.Paragraph(Chunk chunk)
Constructs aParagraph
with a certainChunk
.Paragraph(Phrase phrase)
Constructs aParagraph
with a certainPhrase
.Paragraph(java.lang.String string)
Constructs aParagraph
with a certainString
.Paragraph(java.lang.String string, Font font)
Constructs aParagraph
with a certainString
and a certainFont
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(Element o)
Adds anElement
to theParagraph
.java.util.List<Element>
breakUp()
Breaks this Paragraph up in different parts, separating paragraphs, lists and tables from each other.Paragraph
cloneShallow(boolean spacingBefore)
Creates a shallow clone of the Paragraph.PdfObject
getAccessibleAttribute(PdfName key)
Get the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).java.util.HashMap<PdfName,PdfObject>
getAccessibleAttributes()
Gets all the properties of accessible element.int
getAlignment()
Gets the alignment of this paragraph.float
getExtraParagraphSpace()
Getter for property extraParagraphSpace.float
getFirstLineIndent()
Getter for property firstLineIndent.AccessibleElementId
getId()
float
getIndentationLeft()
Gets the indentation on the left side.float
getIndentationRight()
Gets the indentation on the right side.boolean
getKeepTogether()
Checks if this paragraph has to be kept together on one page.float
getPaddingTop()
PdfName
getRole()
Gets the role of the accessible element.float
getSpacingAfter()
Gets the spacing after.float
getSpacingBefore()
Gets the spacing before.boolean
isInline()
protected void
populateProperties(Paragraph copy, boolean spacingBefore)
void
setAccessibleAttribute(PdfName key, PdfObject value)
Set the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).void
setAlignment(int alignment)
Sets the alignment of this paragraph.void
setExtraParagraphSpace(float extraParagraphSpace)
Setter for property extraParagraphSpace.void
setFirstLineIndent(float firstLineIndent)
Setter for property firstLineIndent.void
setId(AccessibleElementId id)
void
setIndentationLeft(float indentation)
Sets the indentation on the left side.void
setIndentationRight(float indentation)
Sets the indentation on the right side.void
setKeepTogether(boolean keeptogether)
Indicates that the paragraph has to be kept together on one page.void
setPaddingTop(float paddingTop)
void
setRole(PdfName role)
Sets the role of the accessiblee element.void
setSpacingAfter(float spacing)
Sets the spacing after.void
setSpacingBefore(float spacing)
Sets the spacing before.float
spacingAfter()
Deprecated.As of iText 2.1.5, replaced bygetSpacingAfter()
, scheduled for removal at 2.3.0float
spacingBefore()
Deprecated.As of iText 2.1.5, replaced bygetSpacingBefore()
, scheduled for removal at 2.3.0int
type()
Gets the type of the text element.-
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
-
alignment
protected int alignment
The alignment of the text.
-
indentationLeft
protected float indentationLeft
The indentation of this paragraph on the left side.
-
indentationRight
protected float indentationRight
The indentation of this paragraph on the right side.
-
firstLineIndent
private float firstLineIndent
Holds value of property firstLineIndent.
-
spacingBefore
protected float spacingBefore
The spacing before the paragraph.
-
spacingAfter
protected float spacingAfter
The spacing after the paragraph.
-
extraParagraphSpace
private float extraParagraphSpace
Holds value of property extraParagraphSpace.
-
keeptogether
protected boolean keeptogether
Does the paragraph has to be kept together on 1 page.
-
paddingTop
protected float paddingTop
-
role
protected PdfName role
-
id
protected AccessibleElementId id
-
-
Constructor Detail
-
Paragraph
public Paragraph()
Constructs aParagraph
.
-
Paragraph
public Paragraph(float leading)
Constructs aParagraph
with a certain leading.- Parameters:
leading
- the leading
-
Paragraph
public Paragraph(Chunk chunk)
Constructs aParagraph
with a certainChunk
.- Parameters:
chunk
- aChunk
-
Paragraph
public Paragraph(float leading, Chunk chunk)
Constructs aParagraph
with a certainChunk
and a certain leading.- Parameters:
leading
- the leadingchunk
- aChunk
-
Paragraph
public Paragraph(java.lang.String string)
Constructs aParagraph
with a certainString
.- Parameters:
string
- aString
-
Paragraph
public Paragraph(java.lang.String string, Font font)
Constructs aParagraph
with a certainString
and a certainFont
.- Parameters:
string
- aString
font
- aFont
-
Paragraph
public Paragraph(float leading, java.lang.String string)
Constructs aParagraph
with a certainString
and a certain leading.- Parameters:
leading
- the leadingstring
- aString
-
Paragraph
public Paragraph(float leading, java.lang.String string, Font font)
Constructs aParagraph
with a certain leading,String
andFont
.- Parameters:
leading
- the leadingstring
- aString
font
- aFont
-
Paragraph
public Paragraph(Phrase phrase)
Constructs aParagraph
with a certainPhrase
.- Parameters:
phrase
- aPhrase
-
-
Method Detail
-
cloneShallow
public Paragraph cloneShallow(boolean spacingBefore)
Creates a shallow clone of the Paragraph.- Returns:
-
populateProperties
protected void populateProperties(Paragraph copy, boolean spacingBefore)
-
breakUp
public java.util.List<Element> breakUp()
Breaks this Paragraph up in different parts, separating paragraphs, lists and tables from each other.- Returns:
-
type
public int type()
Gets the type of the text element.
-
add
public boolean add(Element o)
Adds anElement
to theParagraph
.
-
setAlignment
public void setAlignment(int alignment)
Sets the alignment of this paragraph.- Parameters:
alignment
- the new alignment
-
setIndentationLeft
public void setIndentationLeft(float indentation)
Description copied from interface:Indentable
Sets the indentation on the left side.- Specified by:
setIndentationLeft
in interfaceIndentable
- Parameters:
indentation
- the new indentation
-
setIndentationRight
public void setIndentationRight(float indentation)
Description copied from interface:Indentable
Sets the indentation on the right side.- Specified by:
setIndentationRight
in interfaceIndentable
- Parameters:
indentation
- the new indentation
-
setFirstLineIndent
public void setFirstLineIndent(float firstLineIndent)
Setter for property firstLineIndent.- Parameters:
firstLineIndent
- New value of property firstLineIndent.
-
setSpacingBefore
public void setSpacingBefore(float spacing)
Description copied from interface:Spaceable
Sets the spacing before.- Specified by:
setSpacingBefore
in interfaceSpaceable
- Parameters:
spacing
- the new spacing
-
setSpacingAfter
public void setSpacingAfter(float spacing)
Description copied from interface:Spaceable
Sets the spacing after.- Specified by:
setSpacingAfter
in interfaceSpaceable
- Parameters:
spacing
- the new spacing
-
setKeepTogether
public void setKeepTogether(boolean keeptogether)
Indicates that the paragraph has to be kept together on one page.- Parameters:
keeptogether
- true of the paragraph may not be split over 2 pages
-
getKeepTogether
public boolean getKeepTogether()
Checks if this paragraph has to be kept together on one page.- Returns:
- true if the paragraph may not be split over 2 pages.
-
getAlignment
public int getAlignment()
Gets the alignment of this paragraph.- Returns:
- alignment
-
getIndentationLeft
public float getIndentationLeft()
Description copied from interface:Indentable
Gets the indentation on the left side.- Specified by:
getIndentationLeft
in interfaceIndentable
- Returns:
- the indentation
-
getIndentationRight
public float getIndentationRight()
Description copied from interface:Indentable
Gets the indentation on the right side.- Specified by:
getIndentationRight
in interfaceIndentable
- Returns:
- the indentation
-
getFirstLineIndent
public float getFirstLineIndent()
Getter for property firstLineIndent.- Returns:
- Value of property firstLineIndent.
-
getSpacingBefore
public float getSpacingBefore()
Description copied from interface:Spaceable
Gets the spacing before.- Specified by:
getSpacingBefore
in interfaceSpaceable
- Returns:
- the spacing
-
getSpacingAfter
public float getSpacingAfter()
Description copied from interface:Spaceable
Gets the spacing after.- Specified by:
getSpacingAfter
in interfaceSpaceable
- Returns:
- the spacing
-
getExtraParagraphSpace
public float getExtraParagraphSpace()
Getter for property extraParagraphSpace.- Returns:
- Value of property extraParagraphSpace.
-
setExtraParagraphSpace
public void setExtraParagraphSpace(float extraParagraphSpace)
Setter for property extraParagraphSpace.- Parameters:
extraParagraphSpace
- New value of property extraParagraphSpace.
-
spacingBefore
@Deprecated public float spacingBefore()
Deprecated.As of iText 2.1.5, replaced bygetSpacingBefore()
, scheduled for removal at 2.3.0Gets the spacing before this paragraph.- Returns:
- the spacing
-
spacingAfter
@Deprecated public float spacingAfter()
Deprecated.As of iText 2.1.5, replaced bygetSpacingAfter()
, scheduled for removal at 2.3.0Gets the spacing after this paragraph.- Returns:
- the spacing
-
getAccessibleAttribute
public PdfObject getAccessibleAttribute(PdfName key)
Description copied from interface:IAccessibleElement
Get the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).- Specified by:
getAccessibleAttribute
in interfaceIAccessibleElement
- Returns:
-
setAccessibleAttribute
public void setAccessibleAttribute(PdfName key, PdfObject value)
Description copied from interface:IAccessibleElement
Set the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).- Specified by:
setAccessibleAttribute
in interfaceIAccessibleElement
-
getAccessibleAttributes
public java.util.HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface:IAccessibleElement
Gets all the properties of accessible element.- Specified by:
getAccessibleAttributes
in interfaceIAccessibleElement
- Returns:
-
getRole
public PdfName getRole()
Description copied from interface:IAccessibleElement
Gets the role of the accessible element.- Specified by:
getRole
in interfaceIAccessibleElement
- Returns:
-
setRole
public void setRole(PdfName role)
Description copied from interface:IAccessibleElement
Sets the role of the accessiblee element. Set role tonull
if you don't want to tag this element. Note that all child elements won't also be tagged.- Specified by:
setRole
in interfaceIAccessibleElement
-
getId
public AccessibleElementId getId()
- Specified by:
getId
in interfaceIAccessibleElement
-
setId
public void setId(AccessibleElementId id)
- Specified by:
setId
in interfaceIAccessibleElement
-
isInline
public boolean isInline()
- Specified by:
isInline
in interfaceIAccessibleElement
-
getPaddingTop
public float getPaddingTop()
- Specified by:
getPaddingTop
in interfaceSpaceable
-
setPaddingTop
public void setPaddingTop(float paddingTop)
- Specified by:
setPaddingTop
in interfaceSpaceable
-
-