Package com.itextpdf.text
Class Paragraph
- All Implemented Interfaces:
Indentable,Spaceable,Element,IAccessibleElement,TextElementArray,Serializable,Cloneable,Iterable<Element>,Collection<Element>,List<Element>,RandomAccess,SequencedCollection<Element>
- Direct Known Subclasses:
ListItem
A
Paragraph is a series of Chunks and/or Phrases.
A Paragraph has the same qualities of a Phrase, 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe alignment of the text.private floatHolds value of property extraParagraphSpace.private floatHolds value of property firstLineIndent.protected AccessibleElementIdprotected floatThe indentation of this paragraph on the left side.protected floatThe indentation of this paragraph on the right side.protected booleanDoes the paragraph has to be kept together on 1 page.protected floatprotected PdfNameprivate static final longprotected floatThe spacing after the paragraph.protected floatThe spacing before the paragraph.Fields inherited from class com.itextpdf.text.Phrase
font, hyphenation, leading, multipliedLeading, tabSettingsFields inherited from class java.util.AbstractList
modCountFields 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
ConstructorsConstructorDescriptionConstructs aParagraph.Paragraph(float leading) Constructs aParagraphwith a certain leading.Constructs aParagraphwith a certainChunkand a certain leading.Constructs aParagraphwith a certainStringand a certain leading.Constructs aParagraphwith a certain leading,StringandFont.Constructs aParagraphwith a certainChunk.Constructs aParagraphwith a certainPhrase.Constructs aParagraphwith a certainString.Constructs aParagraphwith a certainStringand a certainFont. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds anElementto theParagraph.breakUp()Breaks this Paragraph up in different parts, separating paragraphs, lists and tables from each other.cloneShallow(boolean spacingBefore) Creates a shallow clone of the Paragraph.Get the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).Gets all the properties of accessible element.intGets the alignment of this paragraph.floatGetter for property extraParagraphSpace.floatGetter for property firstLineIndent.getId()floatGets the indentation on the left side.floatGets the indentation on the right side.booleanChecks if this paragraph has to be kept together on one page.floatgetRole()Gets the role of the accessible element.floatGets the spacing after.floatGets the spacing before.booleanisInline()protected voidpopulateProperties(Paragraph copy, boolean spacingBefore) voidsetAccessibleAttribute(PdfName key, PdfObject value) Set the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).voidsetAlignment(int alignment) Sets the alignment of this paragraph.voidsetExtraParagraphSpace(float extraParagraphSpace) Setter for property extraParagraphSpace.voidsetFirstLineIndent(float firstLineIndent) Setter for property firstLineIndent.voidvoidsetIndentationLeft(float indentation) Sets the indentation on the left side.voidsetIndentationRight(float indentation) Sets the indentation on the right side.voidsetKeepTogether(boolean keeptogether) Indicates that the paragraph has to be kept together on one page.voidsetPaddingTop(float paddingTop) voidSets the role of the accessiblee element.voidsetSpacingAfter(float spacing) Sets the spacing after.voidsetSpacingBefore(float spacing) Sets the spacing before.floatDeprecated.floatDeprecated.As of iText 2.1.5, replaced bygetSpacingBefore(), scheduled for removal at 2.3.0inttype()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, trimMethods inherited from class java.util.ArrayList
addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
alignment
protected int alignmentThe alignment of the text. -
indentationLeft
protected float indentationLeftThe indentation of this paragraph on the left side. -
indentationRight
protected float indentationRightThe indentation of this paragraph on the right side. -
firstLineIndent
private float firstLineIndentHolds value of property firstLineIndent. -
spacingBefore
protected float spacingBeforeThe spacing before the paragraph. -
spacingAfter
protected float spacingAfterThe spacing after the paragraph. -
extraParagraphSpace
private float extraParagraphSpaceHolds value of property extraParagraphSpace. -
keeptogether
protected boolean keeptogetherDoes the paragraph has to be kept together on 1 page. -
paddingTop
protected float paddingTop -
role
-
accessibleAttributes
-
id
-
-
Constructor Details
-
Paragraph
public Paragraph()Constructs aParagraph. -
Paragraph
public Paragraph(float leading) Constructs aParagraphwith a certain leading.- Parameters:
leading- the leading
-
Paragraph
Constructs aParagraphwith a certainChunk.- Parameters:
chunk- aChunk
-
Paragraph
Constructs aParagraphwith a certainChunkand a certain leading.- Parameters:
leading- the leadingchunk- aChunk
-
Paragraph
Constructs aParagraphwith a certainString.- Parameters:
string- aString
-
Paragraph
Constructs aParagraphwith a certainStringand a certainFont.- Parameters:
string- aStringfont- aFont
-
Paragraph
Constructs aParagraphwith a certainStringand a certain leading.- Parameters:
leading- the leadingstring- aString
-
Paragraph
Constructs aParagraphwith a certain leading,StringandFont.- Parameters:
leading- the leadingstring- aStringfont- aFont
-
Paragraph
Constructs aParagraphwith a certainPhrase.- Parameters:
phrase- aPhrase
-
-
Method Details
-
cloneShallow
Creates a shallow clone of the Paragraph.- Returns:
-
populateProperties
-
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
Adds anElementto theParagraph.- Specified by:
addin interfaceCollection<Element>- Specified by:
addin interfaceList<Element>- Specified by:
addin interfaceTextElementArray- Overrides:
addin classPhrase- Parameters:
o- the element to add.- Returns:
- true is adding the object succeeded
-
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:IndentableSets the indentation on the left side.- Specified by:
setIndentationLeftin interfaceIndentable- Parameters:
indentation- the new indentation
-
setIndentationRight
public void setIndentationRight(float indentation) Description copied from interface:IndentableSets the indentation on the right side.- Specified by:
setIndentationRightin 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:SpaceableSets the spacing before.- Specified by:
setSpacingBeforein interfaceSpaceable- Parameters:
spacing- the new spacing
-
setSpacingAfter
public void setSpacingAfter(float spacing) Description copied from interface:SpaceableSets the spacing after.- Specified by:
setSpacingAfterin 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:IndentableGets the indentation on the left side.- Specified by:
getIndentationLeftin interfaceIndentable- Returns:
- the indentation
-
getIndentationRight
public float getIndentationRight()Description copied from interface:IndentableGets the indentation on the right side.- Specified by:
getIndentationRightin 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:SpaceableGets the spacing before.- Specified by:
getSpacingBeforein interfaceSpaceable- Returns:
- the spacing
-
getSpacingAfter
public float getSpacingAfter()Description copied from interface:SpaceableGets the spacing after.- Specified by:
getSpacingAfterin 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.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.As of iText 2.1.5, replaced bygetSpacingAfter(), scheduled for removal at 2.3.0Gets the spacing after this paragraph.- Returns:
- the spacing
-
getAccessibleAttribute
Description copied from interface:IAccessibleElementGet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
getAccessibleAttributein interfaceIAccessibleElement- Parameters:
key-- Returns:
-
setAccessibleAttribute
Description copied from interface:IAccessibleElementSet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
setAccessibleAttributein interfaceIAccessibleElement- Parameters:
key-value-
-
getAccessibleAttributes
Description copied from interface:IAccessibleElementGets all the properties of accessible element.- Specified by:
getAccessibleAttributesin interfaceIAccessibleElement- Returns:
-
getRole
Description copied from interface:IAccessibleElementGets the role of the accessible element.- Specified by:
getRolein interfaceIAccessibleElement- Returns:
-
setRole
Description copied from interface:IAccessibleElementSets the role of the accessiblee element. Set role tonullif you don't want to tag this element. Note that all child elements won't also be tagged.- Specified by:
setRolein interfaceIAccessibleElement- Parameters:
role-
-
getId
- Specified by:
getIdin interfaceIAccessibleElement
-
setId
- Specified by:
setIdin interfaceIAccessibleElement
-
isInline
public boolean isInline()- Specified by:
isInlinein interfaceIAccessibleElement
-
getPaddingTop
public float getPaddingTop()- Specified by:
getPaddingTopin interfaceSpaceable
-
setPaddingTop
public void setPaddingTop(float paddingTop) - Specified by:
setPaddingTopin interfaceSpaceable
-
getSpacingAfter(), scheduled for removal at 2.3.0