Table of Contents

Class Cell

Namespace
iTextSharp.text
Assembly
iTextSharp.LGPLv2.Core.dll

A Cell is a Rectangle containing other Elements.

public class Cell : Rectangle, ITextElementArray, IElement
Inheritance
Cell
Implements
Derived
Inherited Members

Examples

Table table = new Table(3); table.SetBorderWidth(1); table.SetBorderColor(new Color(0, 0, 255)); table.SetCellpadding(5); table.SetCellspacing(5); Cell cell = new Cell("header"); cell.SetHeader(true); cell.SetColspan(3); table.AddCell(cell); cell = new Cell("example cell with colspan 1 and rowspan 2"); cell.SetRowspan(2); cell.SetBorderColor(new Color(255, 0, 0)); table.AddCell(cell); table.AddCell("1.1"); table.AddCell("2.1"); table.AddCell("1.2"); table.AddCell("2.2");

Remarks

A Cell is a Rectangle containing other Elements. A Cell must be added to a Table. The Table will place the Cell in a Row.

Constructors

Cell()

Constructs an empty Cell.

public Cell()

Cell(bool)

constructors

public Cell(bool dummy)

Parameters

dummy bool

a dummy value

Cell(string)

Constructs a Cell with a certain content.

public Cell(string content)

Parameters

content string

a string

Remarks

The string will be converted into a Paragraph.

Cell(IElement)

Constructs a Cell with a certain Element.

public Cell(IElement element)

Parameters

element IElement

the element

Remarks

if the element is a ListItem, Row or Cell, an exception will be thrown.

Fields

ArrayList

static membervariable

protected IList<IElement> ArrayList

Field Value

IList<IElement>

Percentage

protected bool Percentage

Field Value

bool

colspan

This is the colspan.

protected int colspan

Field Value

int

groupChange

Does this Cell force a group change?

protected bool groupChange

Field Value

bool

header

Is this Cell a header?

protected bool header

Field Value

bool

horizontalAlignment

membervariables

protected int horizontalAlignment

Field Value

int

maxLines

Maximum number of lines allowed in the cell. The default value of this property is not to limit the maximum number of lines (contributed by dperezcar@fcc.es)

protected int maxLines

Field Value

int

noWrap

Will the element have to be wrapped?

protected bool noWrap

Field Value

bool

rowspan

This is the rowspan.

protected int rowspan

Field Value

int

useAscender

Indicates that the largest ascender height should be used to determine the height of the first line. Note that this only has an effect when rendered to PDF. Setting this to true can help with vertical alignment problems.

protected bool useAscender

Field Value

bool

useBorderPadding

Adjusts the cell contents to compensate for border widths. Note that this only has an effect when rendered to PDF.

protected bool useBorderPadding

Field Value

bool

useDescender

Indicates that the largest descender height should be added to the height of the last line (so characters like y don't dip into the border). Note that this only has an effect when rendered to PDF.

protected bool useDescender

Field Value

bool

verticalAlignment

This is the vertical Element.

protected int verticalAlignment

Field Value

int

width

This is the vertical Element.

protected float width

Field Value

float

Properties

Bottom

implementation of the Element-methods

public override float Bottom { get; set; }

Property Value

float

none

Chunks

Gets all the chunks in this element.

public override IList<Chunk> Chunks { get; }

Property Value

IList<Chunk>

an ArrayList

Colspan

Gets the colspan.

public int Colspan { get; set; }

Property Value

int

a value

DummyCell

public static Cell DummyCell { get; }

Property Value

Cell

Elements

Gets Elements.

public IList<IElement> Elements { get; }

Property Value

IList<IElement>

an ArrayList

GroupChange

Does this Cell force a group change?

public bool GroupChange { get; set; }

Property Value

bool

Header

Gets/sets header

public bool Header { get; set; }

Property Value

bool

a value

HorizontalAlignment

Gets/Sets the horizontal Element.

public int HorizontalAlignment { get; set; }

Property Value

int

a value

Leading

Gets/sets the leading.

public float Leading { get; set; }

Property Value

float

a value

Left

This property throws an Exception.

public override float Left { get; set; }

Property Value

float

none

MaxLines

get/set maxLines value

public int MaxLines { get; set; }

Property Value

int

NoWrap

Get nowrap.

public bool NoWrap { get; set; }

Property Value

bool

a value

Right

This property throws an Exception.

public override float Right { get; set; }

Property Value

float

none

Rowspan

Gets/sets the rowspan.

public int Rowspan { get; set; }

Property Value

int

a value

ShowTruncation

get/set showTruncation value

public string ShowTruncation { get; set; }

Property Value

string

Size

Gets the number of Elements in the Cell.

public int Size { get; }

Property Value

int

a size

Top

This property throws an Exception.

public override float Top { get; set; }

Property Value

float

none

Type

Gets the type of the text element.

public override int Type { get; }

Property Value

int

a type

UseAscender

get/set useAscender value

public bool UseAscender { get; set; }

Property Value

bool

UseBorderPadding

get/set useBorderPadding value

public bool UseBorderPadding { get; set; }

Property Value

bool

UseDescender

get/set useDescender value

public bool UseDescender { get; set; }

Property Value

bool

VerticalAlignment

Gets/sets the vertical Element.

public int VerticalAlignment { get; set; }

Property Value

int

a value

Width

Sets the width.

public override float Width { get; set; }

Property Value

float

the new value

Methods

Add(IElement)

Add an Object to this cell.

public bool Add(IElement o)

Parameters

o IElement

the object to add

Returns

bool

always true

AddElement(IElement)

Adds an element to this Cell.

public void AddElement(IElement element)

Parameters

element IElement

the Element to add

Remarks

You can't add ListItems, Rows, Cells, JPEGs, GIFs or PNGs to a Cell.

Clear()

Clears all the Elements of this Cell.

public void Clear()

CreatePdfPCell()

Creates a PdfPCell based on this Cell object. @throws BadElementException

public PdfPCell CreatePdfPCell()

Returns

PdfPCell

a PdfPCell

GetBottom(int)

This method throws an Exception.

public static float GetBottom(int margin)

Parameters

margin int

new value

Returns

float

none

GetLeft(int)

This method throws an Exception.

public static float GetLeft(int margin)

Parameters

margin int

new value

Returns

float

none

GetRight(int)

This method throws an Exception.

public static float GetRight(int margin)

Parameters

margin int

new value

Returns

float

none

GetTop(int)

This method throws an Exception.

public static float GetTop(int margin)

Parameters

margin int

new value

Returns

float

none

GetWidthAsString()

Gets the width as a String.

public string GetWidthAsString()

Returns

string

a value

IsEmpty()

methods to retrieve information

public bool IsEmpty()

Returns

bool

false if there are non-empty Elements in the Cell.

IsTable()

Checks if the Cell is empty.

public bool IsTable()

Returns

bool

false if there are non-empty Elements in the Cell.

IsTag(string)

Checks if a given tag corresponds with this object.

public static bool IsTag(string tag)

Parameters

tag string

the 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 override bool Process(IElementListener listener)

Parameters

listener IElementListener

an IElementListener

Returns

bool

true if the element was processed successfully

SetHorizontalAlignment(string)

methods to set the membervariables

public void SetHorizontalAlignment(string alignment)

Parameters

alignment string

the new alignment as a string

SetVerticalAlignment(string)

Sets the alignment of this paragraph.

public void SetVerticalAlignment(string alignment)

Parameters

alignment string

the new alignment as a string

SetWidth(string)

Sets the width. It can be an absolute value "100" or a percentage "20%"

public void SetWidth(string value)

Parameters

value string

the new value