Skip to main content
Skip table of contents

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
TypeNameMethods
IList<Chunk>Chunks
Gets all the chunks in this element.
get
stringContentget
FontFont
Gets the font of the first Chunk that appears in this Phrase.
get, set
IHyphenationEventHyphenationget, set
floatLeading
Gets/sets the leading of this phrase.
get, set
floatMultipliedLeadingget, set
TabSettingsTabSettingsget, set
floatTotalLeadingget
intType
Gets the type of the text element.
get

Methods

Public methods
ReturnsName
voidAdd(...)
Adds a Chunk, an Anchor or another Phrase
to this Phrase.
boolAddAll(ICollection<T> collection)
voidAddSpecial(IElement obj)
Adds a Object to the Paragraph.
boolHasLeading()
boolIsContent()
boolIsEmpty()
Checks is this Phrase contains no or 1 empty Chunk.
boolIsNestable()
boolProcess(IElementListener listener)
Processes the element by adding it (or the different parts) to an IElementListener .
voidSetLeading(float fixedLeading, float multipliedLeading)
boolTrim()
Protected methods
ReturnsName
boolAddChunk(Chunk chunk)
Adds a Chunk.
Public Static methods
ReturnsName
PhraseGetInstance(...)

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 code

public Phrase()
Summary

Constructs a Phrase without specifying a leading.

Phrase [2/9]

Source code

public Phrase(Phrase phrase)
Arguments
TypeNameDescription
Phrasephrase
Phrase [3/9]

Source code

public Phrase(float leading)
Arguments
TypeNameDescription
floatleadingthe leading
Summary

Constructs a Phrase with a certain leading.

Phrase [4/9]

Source code

public Phrase(Chunk chunk)
Arguments
TypeNameDescription
Chunkchunka Chunk
Summary

Constructs a Phrase with a certain Chunk.

Phrase [5/9]

Source code

public Phrase(float leading, Chunk chunk)
Arguments
TypeNameDescription
floatleadingthe leading
Chunkchunka Chunk
Summary

Constructs a Phrase with a certain Chunk and a certain leading.

Phrase [6/9]

Source code

public Phrase(string str)
Arguments
TypeNameDescription
stringstra string
Summary

Constructs a Phrase with a certain string.

Phrase [7/9]

Source code

public Phrase(string str, Font font)
Arguments
TypeNameDescription
stringstra string
Fontfonta Font
Summary

Constructs a Phrase with a certain string and a certain Font.

Phrase [8/9]

Source code

public Phrase(float leading, string str)
Arguments
TypeNameDescription
floatleadingthe leading
stringstra string
Summary

Constructs a Phrase with a certain leading and a certain string.

Phrase [9/9]

Source code

public Phrase(float leading, string str, Font font)
Arguments
TypeNameDescription
floatleading
stringstr
Fontfont

Methods

Process

Source code

public virtual bool Process(IElementListener listener)
Arguments
TypeNameDescription
IElementListenerlisteneran 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 code

public virtual bool IsContent()
IsNestable

Source code

public virtual bool IsNestable()
Add [1/3]

Source code

public virtual void Add(int index, IElement element)
Arguments
TypeNameDescription
intindexindex at which the specified element is to be inserted
IElementelement
Summary

Adds a Chunk, an Anchor or another Phrase to this Phrase.

Add [2/3]

Source code

public virtual bool Add(string s)
Arguments
TypeNameDescription
strings
Add [3/3]

Source code

public virtual bool Add(IElement element)
Arguments
TypeNameDescription
IElementelement
Summary

Adds a Chunk, Anchor or another Phrase to this Phrase.

Returns

a bool

AddAll

Source code

public virtual bool AddAll<T>(ICollection<T> collection)
where T : IElement
Arguments
TypeNameDescription
ICollection<T>collection
AddChunk

Source code

protected virtual bool AddChunk(Chunk chunk)
Arguments
TypeNameDescription
Chunkchunka 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 code

public virtual void AddSpecial(IElement obj)
Arguments
TypeNameDescription
IElementobjthe object to add.
Summary

Adds a Object to the Paragraph.

IsEmpty

Source code

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

public virtual bool HasLeading()
SetLeading

Source code

public virtual void SetLeading(float fixedLeading, float multipliedLeading)
Arguments
TypeNameDescription
floatfixedLeading
floatmultipliedLeading
GetInstance [1/3]

Source code

public static Phrase GetInstance(string str)
Arguments
TypeNameDescription
stringstr
GetInstance [2/3]

Source code

public static Phrase GetInstance(int leading, string str)
Arguments
TypeNameDescription
intleading
stringstr
GetInstance [3/3]

Source code

public static Phrase GetInstance(int leading, string str, Font font)
Arguments
TypeNameDescription
intleading
stringstr
Fontfont
Trim

Source code

public 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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.