Phrase
Phrase Public class
Description
A Phrase is a series of Chunks.
Diagram
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph iTextSharp.text
iTextSharp.text.Phrase[[Phrase]]
iTextSharp.text.ITextElementArray[[ITextElementArray]]
class iTextSharp.text.ITextElementArray interfaceStyle;
iTextSharp.text.IElement[[IElement]]
class iTextSharp.text.IElement interfaceStyle;
end
subgraph System.Collections.Generic
System.Collections.Generic.List_1[[List]]
end
iTextSharp.text.ITextElementArray --> iTextSharp.text.Phrase
iTextSharp.text.IElement --> iTextSharp.text.ITextElementArray
System.Collections.Generic.List_1 --> iTextSharp.text.Phrase
Members
Properties
Public properties
| Type | Name | Methods |
|---|---|---|
IList<Chunk> | ChunksGets all the chunks in this element. | get |
string | Content | get |
Font | FontGets the font of the first Chunk that appears in this Phrase. | get, set |
IHyphenationEvent | Hyphenation | get, set |
float | LeadingGets/sets the leading of this phrase. | get, set |
float | MultipliedLeading | get, set |
TabSettings | TabSettings | get, set |
float | TotalLeading | get |
int | TypeGets the type of the text element. | get |
Methods
Public methods
| Returns | Name |
|---|---|
void | Add(...)Adds a Chunk, an Anchor or another Phrase to this Phrase. |
bool | AddAll(ICollection<T> collection) |
void | AddSpecial(IElement obj)Adds a Object to the Paragraph. |
bool | HasLeading() |
bool | IsContent() |
bool | IsEmpty()Checks is this Phrase contains no or 1 empty Chunk. |
bool | IsNestable() |
bool | Process(IElementListener listener)Processes the element by adding it (or the different parts) to an IElementListener . |
void | SetLeading(float fixedLeading, float multipliedLeading) |
bool | Trim() |
Protected methods
Public Static methods
| Returns | Name |
|---|---|
Phrase | GetInstance(...) |
Details
Summary
A Phrase is a series of Chunks.
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.
Example
// 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)));
Inheritance
Constructors
Phrase [1/9]
Source codepublic Phrase()
Summary
Constructs a Phrase without specifying a leading.
Phrase [2/9]
Source codepublic Phrase(Phrase phrase)
Arguments
| Type | Name | Description |
|---|---|---|
Phrase | phrase |
Phrase [3/9]
Source codepublic Phrase(float leading)
Arguments
| Type | Name | Description |
|---|---|---|
float | leading | the leading |
Summary
Constructs a Phrase with a certain leading.
Phrase [4/9]
Source codepublic Phrase(Chunk chunk)
Arguments
| Type | Name | Description |
|---|---|---|
Chunk | chunk | a Chunk |
Summary
Constructs a Phrase with a certain Chunk.
Phrase [5/9]
Source codepublic Phrase(float leading, Chunk chunk)
Arguments
| Type | Name | Description |
|---|---|---|
float | leading | the leading |
Chunk | chunk | a Chunk |
Summary
Constructs a Phrase with a certain Chunk and a certain leading.
Phrase [6/9]
Source codepublic Phrase(string str)
Arguments
| Type | Name | Description |
|---|---|---|
string | str | a string |
Summary
Constructs a Phrase with a certain string.
Phrase [7/9]
Source codepublic Phrase(string str, Font font)
Arguments
| Type | Name | Description |
|---|---|---|
string | str | a string |
Font | font | a Font |
Summary
Constructs a Phrase with a certain string and a certain Font.
Phrase [8/9]
Source codepublic Phrase(float leading, string str)
Arguments
| Type | Name | Description |
|---|---|---|
float | leading | the leading |
string | str | a string |
Summary
Constructs a Phrase with a certain leading and a certain string.
Phrase [9/9]
Source codepublic Phrase(float leading, string str, Font font)
Arguments
| Type | Name | Description |
|---|---|---|
float | leading | |
string | str | |
Font | font |
Methods
Process
Source codepublic virtual bool Process(IElementListener listener)
Arguments
| Type | Name | Description |
|---|---|---|
IElementListener | listener | an IElementListener |
Summary
Processes the element by adding it (or the different parts) to an IElementListener .
Returns
true if the element was processed successfully
IsContent
Source codepublic virtual bool IsContent()
IsNestable
Source codepublic virtual bool IsNestable()
Add [1/3]
Source codepublic virtual void Add(int index, IElement element)
Arguments
| Type | Name | Description |
|---|---|---|
int | index | index at which the specified element is to be inserted |
IElement | element |
Summary
Adds a Chunk, an Anchor or another Phrase to this Phrase.
Add [2/3]
Source codepublic virtual bool Add(string s)
Arguments
| Type | Name | Description |
|---|---|---|
string | s |
Add [3/3]
Source codepublic virtual bool Add(IElement element)
Arguments
| Type | Name | Description |
|---|---|---|
IElement | element |
Summary
Adds a Chunk, Anchor or another Phrase to this Phrase.
Returns
a bool
AddAll
Source codepublic virtual bool AddAll<T>(ICollection<T> collection)
where T : IElement
Arguments
| Type | Name | Description |
|---|---|---|
ICollection<T> | collection |
AddChunk
Source codeprotected virtual bool AddChunk(Chunk chunk)
Arguments
| Type | Name | Description |
|---|---|---|
Chunk | chunk | a Chunk |
Summary
Adds a Chunk.
Remarks
This method is a hack to solve a problem I had with phrases that were split between chunks in the wrong place.
Returns
a bool
AddSpecial
Source codepublic virtual void AddSpecial(IElement obj)
Arguments
| Type | Name | Description |
|---|---|---|
IElement | obj | the object to add. |
Summary
Adds a Object to the Paragraph.
IsEmpty
Source codepublic virtual bool IsEmpty()
Summary
Checks is this Phrase contains no or 1 empty Chunk.
Returns
false if the Phrase contains more than one or more non-emptyChunks.
HasLeading
Source codepublic virtual bool HasLeading()
SetLeading
Source codepublic virtual void SetLeading(float fixedLeading, float multipliedLeading)
Arguments
| Type | Name | Description |
|---|---|---|
float | fixedLeading | |
float | multipliedLeading |
GetInstance [1/3]
Source codepublic static Phrase GetInstance(string str)
Arguments
| Type | Name | Description |
|---|---|---|
string | str |
GetInstance [2/3]
Source codepublic static Phrase GetInstance(int leading, string str)
Arguments
| Type | Name | Description |
|---|---|---|
int | leading | |
string | str |
GetInstance [3/3]
Source codepublic static Phrase GetInstance(int leading, string str, Font font)
Arguments
| Type | Name | Description |
|---|---|---|
int | leading | |
string | str | |
Font | font |
Trim
Source codepublic virtual bool Trim()
Properties
Type
public virtual int Type { get; }
Summary
Gets the type of the text element.
Value
a type
Chunks
public virtual IList<Chunk> Chunks { get; }
Summary
Gets all the chunks in this element.
Value
an ArrayList
MultipliedLeading
public virtual float MultipliedLeading { get; set; }
Leading
public virtual float Leading { get; set; }
Summary
Gets/sets the leading of this phrase.
Value
the linespacing
TotalLeading
public virtual float TotalLeading { get; }
Font
public virtual Font Font { get; set; }
Summary
Gets the font of the first Chunk that appears in this Phrase.
Value
a Font
Content
public virtual string Content { get; }
Hyphenation
public virtual IHyphenationEvent Hyphenation { get; set; }
TabSettings
public virtual TabSettings TabSettings { get; set; }
Generated with ModularDoc