Skip to main content
Skip table of contents

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
TypeNameMethods
Dictionary<string, object>Attributes
Sets/Gets the attributes for this Chunk.
get, set
IList<Chunk>Chunks
Gets all the chunks in this element.
get
stringContent
Returns the content of this Chunk.
get
FontFont
Get/set the font of this Chunk.
get, set
floatHorizontalScalingget
AccessibleElementIdIDget, set
boolIsInlineget
PdfNameRoleget, set
intType
Gets the type of the text element.
get

Methods

Public methods
ReturnsName
StringBuilderAppend(string str)
appends some text to this Chunk.
PdfObjectGetAccessibleAttribute(PdfName key)
Dictionary<PdfName, PdfObject>GetAccessibleAttributes()
floatGetCharacterSpacing()
IHyphenationEventGetHyphenation()
ImageGetImage()
Returns the image.
stringGetTextExpansion()
floatGetTextRise()
floatGetWidthPoint()
floatGetWordSpacing()
boolHasAccessibleAttributes()
boolHasAttributes()
Checks the attributes of this Chunk.
boolIsContent()
boolIsEmpty()
Checks is this Chunk is empty.
boolIsNestable()
boolIsTabspace()
boolIsWhitespace()
boolProcess(IElementListener listener)
Processes the element by adding it (or the different parts) to an
IElementListener.
voidSetAccessibleAttribute(PdfName key, PdfObject value)
ChunkSetAction(PdfAction action)
Sets an action for this Chunk.
ChunkSetAnchor(...)
Sets an anchor for this Chunk.
ChunkSetAnnotation(PdfAnnotation annotation)
Sets a generic annotation to this Chunk.
ChunkSetBackground(...)
Sets the color of the background Chunk.
ChunkSetCharacterSpacing(float charSpace)
ChunkSetGenericTag(string text)
Sets the generic tag Chunk.
ChunkSetHorizontalScaling(float scale)
ChunkSetHyphenation(IHyphenationEvent hyphenation)
sets the hyphenation engine to this Chunk.
ChunkSetLocalDestination(string name)
Sets a local destination for this Chunk.
ChunkSetLocalGoto(string name)
Sets a local goto for this Chunk.
ChunkSetNewPage()
Sets a new page tag.
ChunkSetRemoteGoto(...)
Sets a goto for a remote destination for this Chunk.
ChunkSetSkew(float alpha, float beta)
ChunkSetSplitCharacter(ISplitCharacter splitCharacter)
Sets the split characters.
voidSetTextExpansion(string value)
ChunkSetTextRenderMode(int mode, float strokeWidth, BaseColor strokeColor)
ChunkSetTextRise(float rise)
Sets the text displacement relative to the baseline. Positive values rise the text,
negative values lower the text.
ChunkSetUnderline(...)
ChunkSetWordSpacing(float wordSpace)
stringToString()
ChunksetLineHeight(float lineheight)
Public Static methods

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 code

public Chunk()
Summary

Empty constructor.

Chunk [2/12]

Source code

public Chunk(Chunk ck)
Arguments
TypeNameDescription
Chunkck
Chunk [3/12]

Source code

public Chunk(string content, Font font)
Arguments
TypeNameDescription
stringcontentthe content
Fontfontthe font
Summary

Constructs a chunk of text with a certain content and a certain Font.

Chunk [4/12]

Source code

public Chunk(string content)
Arguments
TypeNameDescription
stringcontentthe content
Summary

Constructs a chunk of text with a certain content, without specifying a Font.

Chunk [5/12]

Source code

public Chunk(char c, Font font)
Arguments
TypeNameDescription
charc
Fontfont
Chunk [6/12]

Source code

public Chunk(char c)
Arguments
TypeNameDescription
charc
Chunk [7/12]

Source code

public Chunk(Image image, float offsetX, float offsetY)
Arguments
TypeNameDescription
Imageimagethe image
floatoffsetXthe image offset in the x direction
floatoffsetYthe image offset in the y direction
Summary

Constructs a chunk containing an Image.

Chunk [8/12]

Source code

public Chunk(IDrawInterface separator)
Arguments
TypeNameDescription
IDrawInterfaceseparator
Chunk [9/12]

Source code

public Chunk(IDrawInterface separator, bool vertical)
Arguments
TypeNameDescription
IDrawInterfaceseparator
boolvertical
Chunk [10/12]

Source code

public Chunk(IDrawInterface separator, float tabPosition)
Arguments
TypeNameDescription
IDrawInterfaceseparator
floattabPosition
Chunk [11/12]

Source code

public Chunk(IDrawInterface separator, float tabPosition, bool newline)
Arguments
TypeNameDescription
IDrawInterfaceseparator
floattabPosition
boolnewline
Chunk [12/12]

Source code

public Chunk(Image image, float offsetX, float offsetY, bool changeLeading)
Arguments
TypeNameDescription
Imageimagethe image
floatoffsetXthe image offset in the x direction
floatoffsetYthe image offset in the y direction
boolchangeLeadingtrue if the leading has to be adapted to the image
Summary

Constructs a chunk containing an Image.

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

Append

Source code

public virtual StringBuilder Append(string str)
Arguments
TypeNameDescription
stringstra string
Summary

appends some text to this Chunk.

Returns

a StringBuilder

ToString

Source code

public override string ToString()
IsEmpty

Source code

public virtual bool IsEmpty()
Summary

Checks is this Chunk is empty.

Returns

false if the Chunk contains other characters than space.

GetWidthPoint

Source code

public virtual float GetWidthPoint()
HasAttributes

Source code

public virtual bool HasAttributes()
Summary

Checks the attributes of this Chunk.

Returns

false if there aren't any.

HasAccessibleAttributes

Source code

public bool HasAccessibleAttributes()
SetHorizontalScaling

Source code

public virtual Chunk SetHorizontalScaling(float scale)
Arguments
TypeNameDescription
floatscale
SetUnderline [1/2]

Source code

public virtual Chunk SetUnderline(float thickness, float yPosition)
Arguments
TypeNameDescription
floatthickness
floatyPosition
SetUnderline [2/2]

Source code

public virtual Chunk SetUnderline(BaseColor color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int cap)
Arguments
TypeNameDescription
BaseColorcolor
floatthickness
floatthicknessMul
floatyPosition
floatyPositionMul
intcap
SetTextRise

Source code

public virtual Chunk SetTextRise(float rise)
Arguments
TypeNameDescription
floatrisethe 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 code

public virtual float GetTextRise()
SetSkew

Source code

public virtual Chunk SetSkew(float alpha, float beta)
Arguments
TypeNameDescription
floatalpha
floatbeta
SetBackground [1/2]

Source code

public virtual Chunk SetBackground(BaseColor color)
Arguments
TypeNameDescription
BaseColorcolorthe color of the background
Summary

Sets the color of the background Chunk.

Returns

this Chunk

SetBackground [2/2]

Source code

public virtual Chunk SetBackground(BaseColor color, float extraLeft, float extraBottom, float extraRight, float extraTop)
Arguments
TypeNameDescription
BaseColorcolor
floatextraLeft
floatextraBottom
floatextraRight
floatextraTop
SetTextRenderMode

Source code

public virtual Chunk SetTextRenderMode(int mode, float strokeWidth, BaseColor strokeColor)
Arguments
TypeNameDescription
intmode
floatstrokeWidth
BaseColorstrokeColor
SetSplitCharacter

Source code

public virtual Chunk SetSplitCharacter(ISplitCharacter splitCharacter)
Arguments
TypeNameDescription
ISplitCharactersplitCharacterthe SplitCharacter interface
Summary

Sets the split characters.

Returns

this Chunk

SetHyphenation

Source code

public virtual Chunk SetHyphenation(IHyphenationEvent hyphenation)
Arguments
TypeNameDescription
IHyphenationEventhyphenationthe hyphenation engine
Summary

sets the hyphenation engine to this Chunk.

Returns

this Chunk

SetRemoteGoto [1/2]

Source code

public virtual Chunk SetRemoteGoto(string filename, string name)
Arguments
TypeNameDescription
stringfilenamethe file name of the destination document
stringnamethe 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 code

public virtual Chunk SetRemoteGoto(string filename, int page)
Arguments
TypeNameDescription
stringfilenamethe file name of the destination document
intpagethe 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 code

public virtual Chunk SetLocalGoto(string name)
Arguments
TypeNameDescription
stringnamethe 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 code

public virtual Chunk SetLocalDestination(string name)
Arguments
TypeNameDescription
stringnamethe name for this destination
Summary

Sets a local destination for this Chunk.

Returns

this Chunk

SetGenericTag

Source code

public virtual Chunk SetGenericTag(string text)
Arguments
TypeNameDescription
stringtextthe 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 code

public virtual Chunk setLineHeight(float lineheight)
Arguments
TypeNameDescription
floatlineheight
GetImage

Source code

public virtual Image GetImage()
Summary

Returns the image.

SetAction

Source code

public virtual Chunk SetAction(PdfAction action)
Arguments
TypeNameDescription
PdfActionactionthe action
Summary

Sets an action for this Chunk.

Returns

this Chunk

SetAnchor [1/2]

Source code

public virtual Chunk SetAnchor(Uri url)
Arguments
TypeNameDescription
Uriurlthe Uri to link to
Summary

Sets an anchor for this Chunk.

Returns

this Chunk

SetAnchor [2/2]

Source code

public virtual Chunk SetAnchor(string url)
Arguments
TypeNameDescription
stringurlthe url to link to
Summary

Sets an anchor for this Chunk.

Returns

this Chunk

SetNewPage

Source code

public virtual Chunk SetNewPage()
Summary

Sets a new page tag.

Returns

this Chunk

SetAnnotation

Source code

public virtual Chunk SetAnnotation(PdfAnnotation annotation)
Arguments
TypeNameDescription
PdfAnnotationannotationthe annotation
Summary

Sets a generic annotation to this Chunk.

Returns

this Chunk

IsContent

Source code

public virtual bool IsContent()
IsNestable

Source code

public virtual bool IsNestable()
GetHyphenation

Source code

public virtual IHyphenationEvent GetHyphenation()
SetCharacterSpacing

Source code

public virtual Chunk SetCharacterSpacing(float charSpace)
Arguments
TypeNameDescription
floatcharSpace
GetCharacterSpacing

Source code

public virtual float GetCharacterSpacing()
SetWordSpacing

Source code

public virtual Chunk SetWordSpacing(float wordSpace)
Arguments
TypeNameDescription
floatwordSpace
GetWordSpacing

Source code

public virtual float GetWordSpacing()
CreateWhitespace [1/2]

Source code

public static Chunk CreateWhitespace(string content)
Arguments
TypeNameDescription
stringcontent
CreateWhitespace [2/2]

Source code

public static Chunk CreateWhitespace(string content, bool preserve)
Arguments
TypeNameDescription
stringcontent
boolpreserve
IsWhitespace

Source code

public virtual bool IsWhitespace()
CreateTabspace [1/2]

Source code

public static Chunk CreateTabspace()
CreateTabspace [2/2]

Source code

public static Chunk CreateTabspace(float spacing)
Arguments
TypeNameDescription
floatspacing
IsTabspace

Source code

public virtual bool IsTabspace()
GetAccessibleAttribute

Source code

public virtual PdfObject GetAccessibleAttribute(PdfName key)
Arguments
TypeNameDescription
PdfNamekey
SetAccessibleAttribute

Source code

public virtual void SetAccessibleAttribute(PdfName key, PdfObject value)
Arguments
TypeNameDescription
PdfNamekey
PdfObjectvalue
GetAccessibleAttributes

Source code

public virtual Dictionary<PdfName, PdfObject> GetAccessibleAttributes()
GetTextExpansion

Source code

public virtual string GetTextExpansion()
SetTextExpansion

Source code

public virtual void SetTextExpansion(string value)
Arguments
TypeNameDescription
stringvalue

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

JavaScript errors detected

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

If this problem persists, please contact our support.