com.itextpdf.text
Class Paragraph

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Element>
              extended by com.itextpdf.text.Phrase
                  extended by com.itextpdf.text.Paragraph
All Implemented Interfaces:
Indentable, Spaceable, Element, IAccessibleElement, TextElementArray, Serializable, Cloneable, Iterable<Element>, Collection<Element>, List<Element>, RandomAccess
Direct Known Subclasses:
ListItem

public class Paragraph
extends Phrase
implements Indentable, Spaceable, IAccessibleElement

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:

Example:
 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
protected  HashMap<PdfName,PdfObject> accessibleAttributes
           
protected  int alignment
          The alignment of the text.
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 multipliedLeading
          The text leading that is multiplied by the biggest font size in the line.
protected  PdfName role
           
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, tabSettings
 
Fields inherited from class java.util.AbstractList
modCount
 
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, 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
Paragraph()
          Constructs a Paragraph.
Paragraph(Chunk chunk)
          Constructs a Paragraph with a certain Chunk.
Paragraph(float leading)
          Constructs a Paragraph with a certain leading.
Paragraph(float leading, Chunk chunk)
          Constructs a Paragraph with a certain Chunk and a certain leading.
Paragraph(float leading, String string)
          Constructs a Paragraph with a certain String and a certain leading.
Paragraph(float leading, String string, Font font)
          Constructs a Paragraph with a certain leading, String and Font.
Paragraph(Phrase phrase)
          Constructs a Paragraph with a certain Phrase.
Paragraph(String string)
          Constructs a Paragraph with a certain String.
Paragraph(String string, Font font)
          Constructs a Paragraph with a certain String and a certain Font.
 
Method Summary
 boolean add(Element o)
          Adds an Element to the Paragraph.
 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 in A dictionary + Lang, Alt, ActualText, E).
 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.
 UUID 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 getMultipliedLeading()
          Gets the variable leading
 PdfName getRole()
          Gets the role of the accessible element.
 float getSpacingAfter()
          Gets the spacing after.
 float getSpacingBefore()
          Gets the spacing before.
 float getTotalLeading()
          Gets the total leading.
 void setAccessibleAttribute(PdfName key, PdfObject value)
          Set the attribute of accessible element (everything in A 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(UUID 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 setLeading(float fixedLeading)
          Sets the leading of this phrase.
 void setLeading(float fixedLeading, float multipliedLeading)
          Sets the leading fixed and variable.
 void setMultipliedLeading(float multipliedLeading)
          Sets the variable leading.
 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 by getSpacingAfter(), scheduled for removal at 2.3.0
 float spacingBefore()
          Deprecated. As of iText 2.1.5, replaced by getSpacingBefore(), scheduled for removal at 2.3.0
 int 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, getTabSettings, hasLeading, isContent, isEmpty, isNestable, process, setFont, setHyphenation, setTabSettings, trim
 
Methods inherited from class java.util.ArrayList
addAll, clear, clone, contains, ensureCapacity, get, indexOf, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.itextpdf.text.Element
toString
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

alignment

protected int alignment
The alignment of the text.


multipliedLeading

protected float multipliedLeading
The text leading that is multiplied by the biggest font size in the line.


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.


spacingBefore

protected float spacingBefore
The spacing before the paragraph.


spacingAfter

protected float spacingAfter
The spacing after the paragraph.


keeptogether

protected boolean keeptogether
Does the paragraph has to be kept together on 1 page.


role

protected PdfName role

accessibleAttributes

protected HashMap<PdfName,PdfObject> accessibleAttributes
Constructor Detail

Paragraph

public Paragraph()
Constructs a Paragraph.


Paragraph

public Paragraph(float leading)
Constructs a Paragraph with a certain leading.

Parameters:
leading - the leading

Paragraph

public Paragraph(Chunk chunk)
Constructs a Paragraph with a certain Chunk.

Parameters:
chunk - a Chunk

Paragraph

public Paragraph(float leading,
                 Chunk chunk)
Constructs a Paragraph with a certain Chunk and a certain leading.

Parameters:
leading - the leading
chunk - a Chunk

Paragraph

public Paragraph(String string)
Constructs a Paragraph with a certain String.

Parameters:
string - a String

Paragraph

public Paragraph(String string,
                 Font font)
Constructs a Paragraph with a certain String and a certain Font.

Parameters:
string - a String
font - a Font

Paragraph

public Paragraph(float leading,
                 String string)
Constructs a Paragraph with a certain String and a certain leading.

Parameters:
leading - the leading
string - a String

Paragraph

public Paragraph(float leading,
                 String string,
                 Font font)
Constructs a Paragraph with a certain leading, String and Font.

Parameters:
leading - the leading
string - a String
font - a Font

Paragraph

public Paragraph(Phrase phrase)
Constructs a Paragraph with a certain Phrase.

Parameters:
phrase - a Phrase
Method Detail

cloneShallow

public Paragraph cloneShallow(boolean spacingBefore)
Creates a shallow clone of the Paragraph.

Returns:

breakUp

public 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.

Specified by:
type in interface Element
Overrides:
type in class Phrase
Returns:
a type

add

public boolean add(Element o)
Adds an Element to the Paragraph.

Specified by:
add in interface TextElementArray
Specified by:
add in interface Collection<Element>
Specified by:
add in interface List<Element>
Overrides:
add in class Phrase
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

setLeading

public void setLeading(float fixedLeading)
Description copied from class: Phrase
Sets the leading of this phrase.

Overrides:
setLeading in class Phrase
Parameters:
fixedLeading - the new leading
See Also:
Phrase.setLeading(float)

setMultipliedLeading

public void setMultipliedLeading(float multipliedLeading)
Sets the variable leading. The resultant leading will be multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in the line.

Parameters:
multipliedLeading - the variable leading

setLeading

public void setLeading(float fixedLeading,
                       float multipliedLeading)
Sets the leading fixed and variable. The resultant leading will be fixedLeading+multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in the line.

Parameters:
fixedLeading - the fixed leading
multipliedLeading - the variable leading

setIndentationLeft

public void setIndentationLeft(float indentation)
Description copied from interface: Indentable
Sets the indentation on the left side.

Specified by:
setIndentationLeft in interface Indentable
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 interface Indentable
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 interface Spaceable
Parameters:
spacing - the new spacing

setSpacingAfter

public void setSpacingAfter(float spacing)
Description copied from interface: Spaceable
Sets the spacing after.

Specified by:
setSpacingAfter in interface Spaceable
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

getMultipliedLeading

public float getMultipliedLeading()
Gets the variable leading

Returns:
the leading

getTotalLeading

public float getTotalLeading()
Gets the total leading. This method is based on the assumption that the font of the Paragraph is the font of all the elements that make part of the paragraph. This isn't necessarily true.

Overrides:
getTotalLeading in class Phrase
Returns:
the total leading (fixed and multiplied)

getIndentationLeft

public float getIndentationLeft()
Description copied from interface: Indentable
Gets the indentation on the left side.

Specified by:
getIndentationLeft in interface Indentable
Returns:
the indentation

getIndentationRight

public float getIndentationRight()
Description copied from interface: Indentable
Gets the indentation on the right side.

Specified by:
getIndentationRight in interface Indentable
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 interface Spaceable
Returns:
the spacing

getSpacingAfter

public float getSpacingAfter()
Description copied from interface: Spaceable
Gets the spacing after.

Specified by:
getSpacingAfter in interface Spaceable
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 by getSpacingBefore(), scheduled for removal at 2.3.0

Gets the spacing before this paragraph.

Returns:
the spacing

spacingAfter

@Deprecated
public float spacingAfter()
Deprecated. As of iText 2.1.5, replaced by getSpacingAfter(), scheduled for removal at 2.3.0

Gets 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 in A dictionary + Lang, Alt, ActualText, E).

Specified by:
getAccessibleAttribute in interface IAccessibleElement
Returns:

setAccessibleAttribute

public void setAccessibleAttribute(PdfName key,
                                   PdfObject value)
Description copied from interface: IAccessibleElement
Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).

Specified by:
setAccessibleAttribute in interface IAccessibleElement

getAccessibleAttributes

public HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface: IAccessibleElement
Gets all the properties of accessible element.

Specified by:
getAccessibleAttributes in interface IAccessibleElement
Returns:

getRole

public PdfName getRole()
Description copied from interface: IAccessibleElement
Gets the role of the accessible element.

Specified by:
getRole in interface IAccessibleElement
Returns:

setRole

public void setRole(PdfName role)
Description copied from interface: IAccessibleElement
Sets the role of the accessiblee element. Set role to null if you don't want to tag this element. Note that all child elements won't also be tagged.

Specified by:
setRole in interface IAccessibleElement

getId

public UUID getId()
Specified by:
getId in interface IAccessibleElement

setId

public void setId(UUID id)
Specified by:
setId in interface IAccessibleElement


Copyright © 2013. All Rights Reserved.