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
boola dummy value
Cell(string)
Constructs a Cell with a certain content.
public Cell(string content)
Parameters
content
stringa 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
IElementthe 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
Percentage
protected bool Percentage
Field Value
colspan
This is the colspan.
protected int colspan
Field Value
groupChange
Does this Cell force a group change?
protected bool groupChange
Field Value
header
Is this Cell a header?
protected bool header
Field Value
horizontalAlignment
membervariables
protected int horizontalAlignment
Field Value
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
noWrap
Will the element have to be wrapped?
protected bool noWrap
Field Value
rowspan
This is the rowspan.
protected int rowspan
Field Value
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
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
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
verticalAlignment
This is the vertical Element.
protected int verticalAlignment
Field Value
width
This is the vertical Element.
protected float width
Field Value
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
Colspan
Gets the colspan.
public int Colspan { get; set; }
Property Value
- int
a value
DummyCell
public static Cell DummyCell { get; }
Property Value
Elements
Gets Elements.
public IList<IElement> Elements { get; }
Property Value
GroupChange
Does this Cell force a group change?
public bool GroupChange { get; set; }
Property Value
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
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
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
UseBorderPadding
get/set useBorderPadding value
public bool UseBorderPadding { get; set; }
Property Value
UseDescender
get/set useDescender value
public bool UseDescender { get; set; }
Property Value
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
IElementthe object to add
Returns
- bool
always true
AddElement(IElement)
Adds an element to this Cell.
public void AddElement(IElement element)
Parameters
element
IElementthe 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
intnew value
Returns
- float
none
GetLeft(int)
This method throws an Exception.
public static float GetLeft(int margin)
Parameters
margin
intnew value
Returns
- float
none
GetRight(int)
This method throws an Exception.
public static float GetRight(int margin)
Parameters
margin
intnew value
Returns
- float
none
GetTop(int)
This method throws an Exception.
public static float GetTop(int margin)
Parameters
margin
intnew 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
stringthe 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
IElementListeneran IElementListener
Returns
- bool
true if the element was processed successfully
SetHorizontalAlignment(string)
methods to set the membervariables
public void SetHorizontalAlignment(string alignment)
Parameters
alignment
stringthe new alignment as a string
SetVerticalAlignment(string)
Sets the alignment of this paragraph.
public void SetVerticalAlignment(string alignment)
Parameters
alignment
stringthe 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
stringthe new value