Chunk
Chunk Public class
Description
This is the smallest significant part of text that can be added to a document.
Diagram
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph iTextSharp.text
iTextSharp.text.Chunk[[Chunk]]
iTextSharp.text.IElement[[IElement]]
class iTextSharp.text.IElement interfaceStyle;
end
subgraph iTextSharp.text.pdf.interfaces
iTextSharp.text.pdf.interfaces.IAccessibleElement[[IAccessibleElement]]
class iTextSharp.text.pdf.interfaces.IAccessibleElement interfaceStyle;
end
iTextSharp.text.IElement --> iTextSharp.text.Chunk
iTextSharp.text.pdf.interfaces.IAccessibleElement --> iTextSharp.text.Chunk
Members
Properties
Public properties
| Type | Name | Methods |
|---|---|---|
Dictionary<string, object> | AttributesSets/Gets the attributes for this Chunk. | get, set |
IList<Chunk> | ChunksGets all the chunks in this element. | get |
string | ContentReturns the content of this Chunk. | get |
Font | FontGet/set the font of this Chunk. | get, set |
float | HorizontalScaling | get |
AccessibleElementId | ID | get, set |
bool | IsInline | get |
PdfName | Role | get, set |
int | TypeGets the type of the text element. | get |
Methods
Public methods
| Returns | Name |
|---|---|
StringBuilder | Append(string str)appends some text to this Chunk. |
PdfObject | GetAccessibleAttribute(PdfName key) |
Dictionary<PdfName, PdfObject> | GetAccessibleAttributes() |
float | GetCharacterSpacing() |
IHyphenationEvent | GetHyphenation() |
Image | GetImage()Returns the image. |
string | GetTextExpansion() |
float | GetTextRise() |
float | GetWidthPoint() |
float | GetWordSpacing() |
bool | HasAccessibleAttributes() |
bool | HasAttributes()Checks the attributes of this Chunk. |
bool | IsContent() |
bool | IsEmpty()Checks is this Chunk is empty. |
bool | IsNestable() |
bool | IsTabspace() |
bool | IsWhitespace() |
bool | Process(IElementListener listener)Processes the element by adding it (or the different parts) to an IElementListener. |
void | SetAccessibleAttribute(PdfName key, PdfObject value) |
Chunk | SetAction(PdfAction action)Sets an action for this Chunk. |
Chunk | SetAnchor(...)Sets an anchor for this Chunk. |
Chunk | SetAnnotation(PdfAnnotation annotation)Sets a generic annotation to this Chunk. |
Chunk | SetBackground(...)Sets the color of the background Chunk. |
Chunk | SetCharacterSpacing(float charSpace) |
Chunk | SetGenericTag(string text)Sets the generic tag Chunk. |
Chunk | SetHorizontalScaling(float scale) |
Chunk | SetHyphenation(IHyphenationEvent hyphenation)sets the hyphenation engine to this Chunk. |
Chunk | SetLocalDestination(string name)Sets a local destination for this Chunk. |
Chunk | SetLocalGoto(string name)Sets a local goto for this Chunk. |
Chunk | SetNewPage()Sets a new page tag. |
Chunk | SetRemoteGoto(...)Sets a goto for a remote destination for this Chunk. |
Chunk | SetSkew(float alpha, float beta) |
Chunk | SetSplitCharacter(ISplitCharacter splitCharacter)Sets the split characters. |
void | SetTextExpansion(string value) |
Chunk | SetTextRenderMode(int mode, float strokeWidth, BaseColor strokeColor) |
Chunk | SetTextRise(float rise)Sets the text displacement relative to the baseline. Positive values rise the text, negative values lower the text. |
Chunk | SetUnderline(...) |
Chunk | SetWordSpacing(float wordSpace) |
string | ToString() |
Chunk | setLineHeight(float lineheight) |
Public Static methods
| Returns | Name |
|---|---|
Chunk | CreateTabspace(...) |
Chunk | CreateWhitespace(...) |
Details
Summary
This is the smallest significant part of text that can be added to a document.
Remarks
Most elements can be divided in one or more Chunks. A chunk is a string with a certain Font. all other layoutparameters should be defined in the object to which this chunk of text is added.
Example
Chunk chunk = new Chunk("Hello world", FontFactory.GetFont(FontFactory.COURIER, 20, Font.ITALIC, new BaseColor(255, 0, 0)));
document.Add(chunk);
Inheritance
Constructors
Chunk [1/12]
Source codepublic Chunk()
Summary
Empty constructor.
Chunk [2/12]
Source codepublic Chunk(Chunk ck)
Arguments
| Type | Name | Description |
|---|---|---|
Chunk | ck |
Chunk [3/12]
Source codepublic Chunk(string content, Font font)
Arguments
| Type | Name | Description |
|---|---|---|
string | content | the content |
Font | font | the font |
Summary
Constructs a chunk of text with a certain content and a certain Font.
Chunk [4/12]
Source codepublic Chunk(string content)
Arguments
| Type | Name | Description |
|---|---|---|
string | content | the content |
Summary
Constructs a chunk of text with a certain content, without specifying a Font.
Chunk [5/12]
Source codepublic Chunk(char c, Font font)
Arguments
| Type | Name | Description |
|---|---|---|
char | c | |
Font | font |
Chunk [6/12]
Source codepublic Chunk(char c)
Arguments
| Type | Name | Description |
|---|---|---|
char | c |
Chunk [7/12]
Source codepublic Chunk(Image image, float offsetX, float offsetY)
Arguments
| Type | Name | Description |
|---|---|---|
Image | image | the image |
float | offsetX | the image offset in the x direction |
float | offsetY | the image offset in the y direction |
Summary
Constructs a chunk containing an Image.
Chunk [8/12]
Source codepublic Chunk(IDrawInterface separator)
Arguments
| Type | Name | Description |
|---|---|---|
IDrawInterface | separator |
Chunk [9/12]
Source codepublic Chunk(IDrawInterface separator, bool vertical)
Arguments
| Type | Name | Description |
|---|---|---|
IDrawInterface | separator | |
bool | vertical |
Chunk [10/12]
Source codepublic Chunk(IDrawInterface separator, float tabPosition)
Arguments
| Type | Name | Description |
|---|---|---|
IDrawInterface | separator | |
float | tabPosition |
Chunk [11/12]
Source codepublic Chunk(IDrawInterface separator, float tabPosition, bool newline)
Arguments
| Type | Name | Description |
|---|---|---|
IDrawInterface | separator | |
float | tabPosition | |
bool | newline |
Chunk [12/12]
Source codepublic Chunk(Image image, float offsetX, float offsetY, bool changeLeading)
Arguments
| Type | Name | Description |
|---|---|---|
Image | image | the image |
float | offsetX | the image offset in the x direction |
float | offsetY | the image offset in the y direction |
bool | changeLeading | true if the leading has to be adapted to the image |
Summary
Constructs a chunk containing an Image.
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
Append
Source codepublic virtual StringBuilder Append(string str)
Arguments
| Type | Name | Description |
|---|---|---|
string | str | a string |
Summary
appends some text to this Chunk.
Returns
a StringBuilder
ToString
Source codepublic override string ToString()
IsEmpty
Source codepublic virtual bool IsEmpty()
Summary
Checks is this Chunk is empty.
Returns
false if the Chunk contains other characters than space.
GetWidthPoint
Source codepublic virtual float GetWidthPoint()
HasAttributes
Source codepublic virtual bool HasAttributes()
Summary
Checks the attributes of this Chunk.
Returns
false if there aren't any.
HasAccessibleAttributes
Source codepublic bool HasAccessibleAttributes()
SetHorizontalScaling
Source codepublic virtual Chunk SetHorizontalScaling(float scale)
Arguments
| Type | Name | Description |
|---|---|---|
float | scale |
SetUnderline [1/2]
Source codepublic virtual Chunk SetUnderline(float thickness, float yPosition)
Arguments
| Type | Name | Description |
|---|---|---|
float | thickness | |
float | yPosition |
SetUnderline [2/2]
Source codepublic virtual Chunk SetUnderline(BaseColor color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int cap)
Arguments
| Type | Name | Description |
|---|---|---|
BaseColor | color | |
float | thickness | |
float | thicknessMul | |
float | yPosition | |
float | yPositionMul | |
int | cap |
SetTextRise
Source codepublic virtual Chunk SetTextRise(float rise)
Arguments
| Type | Name | Description |
|---|---|---|
float | rise | the displacement in points |
Summary
Sets the text displacement relative to the baseline. Positive values rise the text, negative values lower the text.
Remarks
It can be used to implement sub/basescript.
Returns
this Chunk
GetTextRise
Source codepublic virtual float GetTextRise()
SetSkew
Source codepublic virtual Chunk SetSkew(float alpha, float beta)
Arguments
| Type | Name | Description |
|---|---|---|
float | alpha | |
float | beta |
SetBackground [1/2]
Source codepublic virtual Chunk SetBackground(BaseColor color)
Arguments
| Type | Name | Description |
|---|---|---|
BaseColor | color | the color of the background |
Summary
Sets the color of the background Chunk.
Returns
this Chunk
SetBackground [2/2]
Source codepublic virtual Chunk SetBackground(BaseColor color, float extraLeft, float extraBottom, float extraRight, float extraTop)
Arguments
| Type | Name | Description |
|---|---|---|
BaseColor | color | |
float | extraLeft | |
float | extraBottom | |
float | extraRight | |
float | extraTop |
SetTextRenderMode
Source codepublic virtual Chunk SetTextRenderMode(int mode, float strokeWidth, BaseColor strokeColor)
Arguments
| Type | Name | Description |
|---|---|---|
int | mode | |
float | strokeWidth | |
BaseColor | strokeColor |
SetSplitCharacter
Source codepublic virtual Chunk SetSplitCharacter(ISplitCharacter splitCharacter)
Arguments
| Type | Name | Description |
|---|---|---|
ISplitCharacter | splitCharacter | the SplitCharacter interface |
Summary
Sets the split characters.
Returns
this Chunk
SetHyphenation
Source codepublic virtual Chunk SetHyphenation(IHyphenationEvent hyphenation)
Arguments
| Type | Name | Description |
|---|---|---|
IHyphenationEvent | hyphenation | the hyphenation engine |
Summary
sets the hyphenation engine to this Chunk.
Returns
this Chunk
SetRemoteGoto [1/2]
Source codepublic virtual Chunk SetRemoteGoto(string filename, string name)
Arguments
| Type | Name | Description |
|---|---|---|
string | filename | the file name of the destination document |
string | name | the name of the destination to go to |
Summary
Sets a goto for a remote destination for this Chunk.
Returns
this Chunk
SetRemoteGoto [2/2]
Source codepublic virtual Chunk SetRemoteGoto(string filename, int page)
Arguments
| Type | Name | Description |
|---|---|---|
string | filename | the file name of the destination document |
int | page | the page of the destination to go to. First page is 1 |
Summary
Sets a goto for a remote destination for this Chunk.
Returns
this Chunk
SetLocalGoto
Source codepublic virtual Chunk SetLocalGoto(string name)
Arguments
| Type | Name | Description |
|---|---|---|
string | name | the name of the destination to go to |
Summary
Sets a local goto for this Chunk.
Remarks
There must be a local destination matching the name.
Returns
this Chunk
SetLocalDestination
Source codepublic virtual Chunk SetLocalDestination(string name)
Arguments
| Type | Name | Description |
|---|---|---|
string | name | the name for this destination |
Summary
Sets a local destination for this Chunk.
Returns
this Chunk
SetGenericTag
Source codepublic virtual Chunk SetGenericTag(string text)
Arguments
| Type | Name | Description |
|---|---|---|
string | text | the text for the tag |
Summary
Sets the generic tag Chunk.
Remarks
The text for this tag can be retrieved with PdfPageEvent.
Returns
this Chunk
setLineHeight
Source codepublic virtual Chunk setLineHeight(float lineheight)
Arguments
| Type | Name | Description |
|---|---|---|
float | lineheight |
GetImage
Source codepublic virtual Image GetImage()
Summary
Returns the image.
SetAction
Source codepublic virtual Chunk SetAction(PdfAction action)
Arguments
| Type | Name | Description |
|---|---|---|
PdfAction | action | the action |
Summary
Sets an action for this Chunk.
Returns
this Chunk
SetAnchor [1/2]
Source codepublic virtual Chunk SetAnchor(Uri url)
Arguments
| Type | Name | Description |
|---|---|---|
Uri | url | the Uri to link to |
Summary
Sets an anchor for this Chunk.
Returns
this Chunk
SetAnchor [2/2]
Source codepublic virtual Chunk SetAnchor(string url)
Arguments
| Type | Name | Description |
|---|---|---|
string | url | the url to link to |
Summary
Sets an anchor for this Chunk.
Returns
this Chunk
SetNewPage
Source codepublic virtual Chunk SetNewPage()
Summary
Sets a new page tag.
Returns
this Chunk
SetAnnotation
Source codepublic virtual Chunk SetAnnotation(PdfAnnotation annotation)
Arguments
| Type | Name | Description |
|---|---|---|
PdfAnnotation | annotation | the annotation |
Summary
Sets a generic annotation to this Chunk.
Returns
this Chunk
IsContent
Source codepublic virtual bool IsContent()
IsNestable
Source codepublic virtual bool IsNestable()
GetHyphenation
Source codepublic virtual IHyphenationEvent GetHyphenation()
SetCharacterSpacing
Source codepublic virtual Chunk SetCharacterSpacing(float charSpace)
Arguments
| Type | Name | Description |
|---|---|---|
float | charSpace |
GetCharacterSpacing
Source codepublic virtual float GetCharacterSpacing()
SetWordSpacing
Source codepublic virtual Chunk SetWordSpacing(float wordSpace)
Arguments
| Type | Name | Description |
|---|---|---|
float | wordSpace |
GetWordSpacing
Source codepublic virtual float GetWordSpacing()
CreateWhitespace [1/2]
Source codepublic static Chunk CreateWhitespace(string content)
Arguments
| Type | Name | Description |
|---|---|---|
string | content |
CreateWhitespace [2/2]
Source codepublic static Chunk CreateWhitespace(string content, bool preserve)
Arguments
| Type | Name | Description |
|---|---|---|
string | content | |
bool | preserve |
IsWhitespace
Source codepublic virtual bool IsWhitespace()
CreateTabspace [1/2]
Source codepublic static Chunk CreateTabspace()
CreateTabspace [2/2]
Source codepublic static Chunk CreateTabspace(float spacing)
Arguments
| Type | Name | Description |
|---|---|---|
float | spacing |
IsTabspace
Source codepublic virtual bool IsTabspace()
GetAccessibleAttribute
Source codepublic virtual PdfObject GetAccessibleAttribute(PdfName key)
Arguments
| Type | Name | Description |
|---|---|---|
PdfName | key |
SetAccessibleAttribute
Source codepublic virtual void SetAccessibleAttribute(PdfName key, PdfObject value)
Arguments
GetAccessibleAttributes
Source codepublic virtual Dictionary<PdfName, PdfObject> GetAccessibleAttributes()
GetTextExpansion
Source codepublic virtual string GetTextExpansion()
SetTextExpansion
Source codepublic virtual void SetTextExpansion(string value)
Arguments
| Type | Name | Description |
|---|---|---|
string | value |
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
Font
public virtual Font Font { get; set; }
Summary
Get/set the font of this Chunk.
Value
a Font
Content
public virtual string Content { get; }
Summary
Returns the content of this Chunk.
Value
a string
Attributes
public virtual Dictionary<string, object> Attributes { get; set; }
Summary
Sets/Gets the attributes for this Chunk.
Remarks
It may be null.
Value
a Hashtable
HorizontalScaling
public virtual float HorizontalScaling { get; }
Role
public virtual PdfName Role { get; set; }
ID
public virtual AccessibleElementId ID { get; set; }
IsInline
public virtual bool IsInline { get; }
Generated with ModularDoc