Class Phrase
- Namespace
- iTextSharp.text
- Assembly
- iTextSharp.LGPLv2.Core.dll
A Phrase is a series of Chunks.
public class Phrase : List<IElement>, IList<IElement>, ICollection<IElement>, IList, ICollection, IReadOnlyList<IElement>, IReadOnlyCollection<IElement>, IEnumerable<IElement>, IEnumerable, ITextElementArray, IElement
- Inheritance
-
Phrase
- Implements
- Derived
- Inherited Members
- Extension Methods
Examples
// When no parameters are passed, the default leading = 16 Phrase phrase0 = new Phrase(); Phrase phrase1 = new Phrase("this is a phrase"); // In this example the leading is passed as a parameter Phrase phrase2 = new Phrase(16, "this is a phrase with leading 16"); // When a Font is passed (explicitely or embedded in a chunk), the default leading = 1.5 * size of the font Phrase phrase3 = new Phrase("this is a phrase with a red, normal font Courier, size 12", FontFactory.GetFont(FontFactory.COURIER, 12, Font.NORMAL, new Color(255, 0, 0))); Phrase phrase4 = new Phrase(new Chunk("this is a phrase")); Phrase phrase5 = new Phrase(18, new Chunk("this is a phrase", FontFactory.GetFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0, 0)));
Remarks
A Phrase has a main Font, but some chunks within the phrase can have a Font that differs from the main Font. All the Chunks in a Phrase have the same leading.
Constructors
Phrase()
constructors
public Phrase()
Phrase(float)
Constructs a Phrase with a certain leading.
public Phrase(float leading)
Parameters
leading
floatthe leading
Phrase(float, string)
Constructs a Phrase with a certain leading and a certain string.
public Phrase(float leading, string str)
Parameters
Phrase(float, string, Font)
public Phrase(float leading, string str, Font font)
Parameters
Phrase(float, Chunk)
Constructs a Phrase with a certain Chunk and a certain leading.
public Phrase(float leading, Chunk chunk)
Parameters
Phrase(string)
Constructs a Phrase with a certain string.
public Phrase(string str)
Parameters
str
stringa string
Phrase(string, Font)
Constructs a Phrase with a certain string and a certain Font.
public Phrase(string str, Font font)
Parameters
Phrase(Chunk)
Constructs a Phrase with a certain Chunk.
public Phrase(Chunk chunk)
Parameters
chunk
Chunka Chunk
Phrase(Phrase)
Copy constructor for Phrase .
public Phrase(Phrase phrase)
Parameters
phrase
Phrase
Fields
font
membervariables
protected Font font
Field Value
hyphenation
Null, unless the Phrase has to be hyphenated. @since 2.1.2
protected IHyphenationEvent hyphenation
Field Value
leading
This is the leading of this phrase.
protected float leading
Field Value
Properties
Chunks
Gets all the chunks in this element.
public virtual IList<Chunk> Chunks { get; }
Property Value
Content
Returns the content as a String object. This method differs from toString because toString will return an ArrayList with the toString value of the Chunks in this Phrase.
public string Content { get; }
Property Value
Font
Gets the font of the first Chunk that appears in this Phrase.
public Font Font { get; set; }
Property Value
- Font
a Font
Hyphenation
Setter/getter for the hyphenation. @since 2.1.2
public IHyphenationEvent Hyphenation { get; set; }
Property Value
Leading
Gets/sets the leading of this phrase.
public virtual float Leading { get; set; }
Property Value
- float
the linespacing
Type
Gets the type of the text element.
public virtual int Type { get; }
Property Value
- int
a type
Methods
Add(int, object)
Adds a Chunk, an Anchor or another Phrase to this Phrase.
public virtual void Add(int index, object o)
Parameters
index
intindex at which the specified element is to be inserted
o
objectan object of type Chunk, Anchor, or Phrase
Add(IElement)
overriding some of the ArrayList-methods
public virtual bool Add(IElement o)
Parameters
o
IElementan object of type Chunk, Anchor or Phrase
Returns
- bool
a bool
AddAll<T>(ICollection<T>)
Adds a collection of Chunks to this Phrase.
public bool AddAll<T>(ICollection<T> collection) where T : IElement
Parameters
collection
ICollection<T>a collection of Chunks, Anchors and Phrases.
Returns
- bool
true if the action succeeded, false if not.
Type Parameters
T
AddChunk(Chunk)
Adds a Chunk.
protected bool AddChunk(Chunk chunk)
Parameters
chunk
Chunka Chunk
Returns
- bool
a bool
Remarks
This method is a hack to solve a problem I had with phrases that were split between chunks in the wrong place.
AddSpecial(IElement)
Adds a Object to the Paragraph.
public void AddSpecial(IElement obj)
Parameters
obj
IElementthe object to add.
GetInstance(int, string)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
public static Phrase GetInstance(int leading, string str)
Parameters
Returns
- Phrase
a newly constructed Phrase
GetInstance(int, string, Font)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
public static Phrase GetInstance(int leading, string str, Font font)
Parameters
Returns
- Phrase
a newly constructed Phrase
GetInstance(string)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
public static Phrase GetInstance(string str)
Parameters
str
string
Returns
- Phrase
a newly constructed Phrase
HasLeading()
public bool HasLeading()
Returns
IsContent()
@see com.lowagie.text.Element#isContent() @since iText 2.0.8
public bool IsContent()
Returns
IsEmpty()
Checks is this Phrase contains no or 1 empty Chunk.
public bool IsEmpty()
Returns
- bool
false if the Phrase contains more than one or more non-emptyChunks.
IsNestable()
@see com.lowagie.text.Element#isNestable() @since iText 2.0.8
public bool IsNestable()
Returns
IsTag(string)
Checks if a given tag corresponds with this object.
public static bool IsTag(string tag)
Parameters
tag
stringthe given tag
Returns
- bool
true if the tag corresponds
Process(IElementListener)
Processes the element by adding it (or the different parts) to an IElementListener.
public virtual bool Process(IElementListener listener)
Parameters
listener
IElementListeneran IElementListener
Returns
- bool
true if the element was processed successfully