com.lowagie.text.pdf

Class PdfCell

public class PdfCell extends Rectangle

A PdfCell is the PDF translation of a Cell.

A PdfCell is an ArrayList of PdfLines.

When using variable borders (isUseVariableBorders() == true), the borders are drawn completely inside the cell Rectangle so that adjacent cell borders will not overlap. Otherwise, the borders are drawn on top of the edges of the cell Rectangle and will overlap the borders of adjacent cells.

See Also: Rectangle Cell PdfLine PdfTable

Field Summary
floatcellpadding
This is the cellpadding of the cell.
floatcellspacing
This is the cellspacing of the cell.
floatcontentHeight
This is the total height of the content of the cell.
PdfLinefirstLine
intgroupNumber
This is the number of the group the cell is in.
booleanheader
Indicates if this cell belongs to the header of a PdfTable
ArrayListimages
These are the Images in the Cell.
PdfLinelastLine
floatleading
This is the leading of the lines.
PdfLineline
These are the PdfLines in the Cell.
ArrayListlines
These are the PdfLines in the Cell.
intrownumber
This is the number of the row the cell is in.
introwspan
This is the rowspan of the cell.
booleanuseAscender
Indicates that the largest ascender height should be used to determine the height of the first line.
booleanuseBorderPadding
Adjusts the cell contents to compensate for border widths.
booleanuseDescender
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).
intverticalAlignment
Constructor Summary
PdfCell(Cell cell, int rownumber, float left, float right, float top, float cellspacing, float cellpadding)
Constructs a PdfCell-object.
Method Summary
floataddImage(Image i, float left, float right, float extraHeight, int alignment)
Adds an image to this Cell.
voidaddLine(PdfLine line)
voidaddList(List list, float left, float right, int alignment)
floatbottom()
Returns the lower left y-coordinate.
floatcellpadding()
Gets the cellpadding of a cell..
floatcellspacing()
Gets the cellspacing of a cell.
floatfirstLineRealHeight()
Calculates what the height of the first line should be so that the content will be flush with the top.
voidflushCurrentLine()
floatgetBorderWidthInside(int side)
Gets the amount of the border for the specified side that is inside the Rectangle.
floatgetBottom()
Returns the lower left y-coordinate.
intgetGroupNumber()
Gets the number of the group this cell is in..
ArrayListgetImages(float top, float bottom)
Gets the images of a cell that can be drawn between certain limits.
floatgetLeft()
Returns the lower left x-coordinaat.
ArrayListgetLines(float top, float bottom)
Gets the lines of a cell that can be drawn between certain limits.
floatgetRight()
Returns the upper right x-coordinate.
floatgetTop()
Returns the upper right y-coordinate.
booleanisHeader()
Checks if this cell belongs to the header of a PdfTable.
booleanisUseAscender()
Gets the value of
booleanisUseBorderPadding()
Gets the value of useBorderPadding.
booleanisUseDescender()
gets the value of
floatleading()
Gets the leading of a cell.
floatleft()
Returns the lower left x-coordinaat.
booleanmayBeRemoved()
Checks if the cell may be removed.
protected voidprocessActions(Element element, PdfAction action, ArrayList allActions)
Processes all actions contained in the cell.
Rectanglerectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.
floatremainingHeight()
Returns the height needed to draw the remaining text.
intremainingLines()
Returns the number of lines in the cell that are not empty.
PdfLineremoveLine(int index)
floatright()
Returns the upper right x-coordinate.
intrownumber()
Gets the number of the row this cell is in..
introwspan()
Gets the rowspan of a cell.
voidsetBottom(float value)
Sets the bottom of the Rectangle and determines the proper {link #verticalOffset} to appropriately align the contents vertically.
voidsetGroupNumber(int number)
Sets the group number.
voidsetHeader()
Indicates that this cell belongs to the header of a PdfTable.
voidsetUseAscender(boolean use)
Sets the value of useAscender.
voidsetUseBorderPadding(boolean use)
Sets the value of useBorderPadding.
voidsetUseDescender(boolean use)
Sets the value of useDescender.
intsize()
Returns the number of lines in the cell.
floattop()
Returns the upper right y-coordinate.

Field Detail

cellpadding

private float cellpadding
This is the cellpadding of the cell.

cellspacing

private float cellspacing
This is the cellspacing of the cell.

contentHeight

private float contentHeight
This is the total height of the content of the cell. Note that the actual cell height may be larger due to another cell on the row *

firstLine

private PdfLine firstLine

groupNumber

private int groupNumber
This is the number of the group the cell is in.

header

private boolean header
Indicates if this cell belongs to the header of a PdfTable

images

private ArrayList images
These are the Images in the Cell.

lastLine

private PdfLine lastLine

leading

private float leading
This is the leading of the lines.

line

private PdfLine line
These are the PdfLines in the Cell.

lines

private ArrayList lines
These are the PdfLines in the Cell.

rownumber

private int rownumber
This is the number of the row the cell is in.

rowspan

private int rowspan
This is the rowspan of the cell.

useAscender

private boolean useAscender
Indicates that the largest ascender height should be used to determine the height of the first line. Setting this to true can help with vertical alignment problems.

useBorderPadding

private boolean useBorderPadding
Adjusts the cell contents to compensate for border widths.

useDescender

private boolean 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).

verticalAlignment

private int verticalAlignment

Constructor Detail

PdfCell

public PdfCell(Cell cell, int rownumber, float left, float right, float top, float cellspacing, float cellpadding)
Constructs a PdfCell-object.

Parameters: cell the original Cell rownumber the number of the Row the Cell was in. left the left border of the PdfCell right the right border of the PdfCell top the top border of the PdfCell cellspacing the cellspacing of the Table cellpadding the cellpadding of the Table

Method Detail

addImage

private float addImage(Image i, float left, float right, float extraHeight, int alignment)
Adds an image to this Cell.

Parameters: i the image to add left the left border right the right border extraHeight extra height to add above image alignment horizontal alignment (constant from Element class)

Returns: the height of the image

addLine

private void addLine(PdfLine line)

addList

private void addList(List list, float left, float right, int alignment)

bottom

public float bottom()

Deprecated: Use getBottom instead

Returns the lower left y-coordinate.

Returns: the lower left y-coordinate

cellpadding

public float cellpadding()
Gets the cellpadding of a cell..

Returns: a value

cellspacing

public float cellspacing()
Gets the cellspacing of a cell.

Returns: a value

firstLineRealHeight

private float firstLineRealHeight()
Calculates what the height of the first line should be so that the content will be flush with the top. For text, this is the height of the ascender. For an image, it is the actual height of the image.

Returns: the real height of the first line

flushCurrentLine

private void flushCurrentLine()

getBorderWidthInside

private float getBorderWidthInside(int side)
Gets the amount of the border for the specified side that is inside the Rectangle. For non-variable width borders this is only 1/2 the border width on that side. This always returns 0 if useBorderPadding is false;

Parameters: side the side to check. One of the side constants in Rectangle

Returns: the borderwidth inside the cell

getBottom

public float getBottom()
Returns the lower left y-coordinate.

Returns: the lower left y-coordinate

getGroupNumber

public int getGroupNumber()
Gets the number of the group this cell is in..

Returns: a number

getImages

public ArrayList getImages(float top, float bottom)
Gets the images of a cell that can be drawn between certain limits.

Remark: all the lines that can be drawn are removed from the object!

Parameters: top the top of the part of the table that can be drawn bottom the bottom of the part of the table that can be drawn

Returns: an ArrayList of Images

getLeft

public float getLeft()
Returns the lower left x-coordinaat.

Returns: the lower left x-coordinaat

getLines

public ArrayList getLines(float top, float bottom)
Gets the lines of a cell that can be drawn between certain limits.

Remark: all the lines that can be drawn are removed from the object!

Parameters: top the top of the part of the table that can be drawn bottom the bottom of the part of the table that can be drawn

Returns: an ArrayList of PdfLines

getRight

public float getRight()
Returns the upper right x-coordinate.

Returns: the upper right x-coordinate

getTop

public float getTop()
Returns the upper right y-coordinate.

Returns: the upper right y-coordinate

isHeader

boolean isHeader()
Checks if this cell belongs to the header of a PdfTable.

Returns: void

isUseAscender

public boolean isUseAscender()
Gets the value of useAscender

Returns: useAscender

isUseBorderPadding

public boolean isUseBorderPadding()
Gets the value of useBorderPadding.

Returns: useBorderPadding

isUseDescender

public boolean isUseDescender()
gets the value of useDescender

Returns: useDescender

leading

public float leading()
Gets the leading of a cell.

Returns: the leading of the lines is the cell.

left

public float left()

Deprecated: Use getLeft instead

Returns the lower left x-coordinaat.

Returns: the lower left x-coordinaat

mayBeRemoved

boolean mayBeRemoved()
Checks if the cell may be removed.

Headers may allways be removed, even if they are drawn only partially: they will be repeated on each following page anyway!

Returns: true if all the lines are allready drawn; false otherwise.

processActions

protected void processActions(Element element, PdfAction action, ArrayList allActions)
Processes all actions contained in the cell.

Parameters: element an element in the cell action an action that should be coupled to the cell allActions

rectangle

public Rectangle rectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.

Parameters: top the top position bottom the bottom position

Returns: a Rectangle

remainingHeight

public float remainingHeight()
Returns the height needed to draw the remaining text.

Returns: a height

remainingLines

public int remainingLines()
Returns the number of lines in the cell that are not empty.

Returns: a value

removeLine

private PdfLine removeLine(int index)

right

public float right()

Deprecated: Use getRight instead

Returns the upper right x-coordinate.

Returns: the upper right x-coordinate

rownumber

public int rownumber()
Gets the number of the row this cell is in..

Returns: a number

rowspan

public int rowspan()
Gets the rowspan of a cell.

Returns: the rowspan of the cell

setBottom

public void setBottom(float value)
Sets the bottom of the Rectangle and determines the proper {link #verticalOffset} to appropriately align the contents vertically.

Parameters: value

setGroupNumber

void setGroupNumber(int number)
Sets the group number.

Parameters: number

setHeader

void setHeader()
Indicates that this cell belongs to the header of a PdfTable.

setUseAscender

public void setUseAscender(boolean use)
Sets the value of useAscender.

Parameters: use use ascender height if true

setUseBorderPadding

public void setUseBorderPadding(boolean use)
Sets the value of useBorderPadding.

Parameters: use adjust layour for borders if true

setUseDescender

public void setUseDescender(boolean use)
Sets the value of useDescender.

Parameters: use use descender height if true

size

public int size()
Returns the number of lines in the cell.

Returns: a value

top

public float top()

Deprecated: Use getTop instead

Returns the upper right y-coordinate.

Returns: the upper right y-coordinate