public class Table extends BlockElement<Table> implements ILargeElement
Table is a layout element that represents data in a two-dimensional
grid. It is filled with cells, ordered in rows and columns.
It is an implementation of ILargeElement, which means it can be flushed
to the canvas, in order to reclaim memory that is locked up.| Modifier and Type | Class and Description |
|---|---|
static class |
Table.RowRange
A simple object which holds the row numbers of a section of a table.
|
| Modifier and Type | Field and Description |
|---|---|
protected PdfName |
role |
protected AccessibilityProperties |
tagProperties |
childElements, nextRenderer, stylesproperties| Constructor and Description |
|---|
Table(float[] columnWidths)
Constructs a
Table with the relative column widths. |
Table(float[] columnWidths,
boolean largeTable)
Constructs a
Table with the relative column widths. |
Table(int numColumns)
Constructs a
Table with numColumns columns. |
Table(int numColumns,
boolean largeTable)
Constructs a
Table with numColumns columns. |
| Modifier and Type | Method and Description |
|---|---|
<T extends IElement> |
addCell(BlockElement<T> blockElement)
Adds a new cell with received blockElement as a content.
|
Table |
addCell(Cell cell)
Adds a new cell to the table.
|
Table |
addCell(Image image)
Adds a new cell with received image as a content.
|
Table |
addCell(String content)
Adds a new cell with received string as a content.
|
<T extends IElement> |
addFooterCell(BlockElement<T> blockElement)
Adds a new cell with received blockElement as a content to the footer of the table.
|
Table |
addFooterCell(Cell footerCell)
Adds a new cell to the footer of the table.
|
Table |
addFooterCell(Image image)
Adds a new cell with received image as a content to the footer of the table.
|
Table |
addFooterCell(String content)
Adds a new cell with received string as a content to the footer of the table.
|
<T extends IElement> |
addHeaderCell(BlockElement<T> blockElement)
Adds a new cell with received blockElement as a content to the header of the table.
|
Table |
addHeaderCell(Cell headerCell)
Adds a new cell to the header of the table.
|
Table |
addHeaderCell(Image image)
Adds a new cell with received image to the header of the table.
|
Table |
addHeaderCell(String content)
Adds a new cell with received string as a content to the header of the table.
|
protected void |
calculateWidths() |
void |
complete()
Indicates that all the desired content has been added to this large element.
|
IRenderer |
createRendererSubTree()
Creates a renderer subtree with root in the current table element.
|
void |
flush()
Writes the newly added content to the document.
|
void |
flushContent()
Flushes the content which has just been added to the document.
|
AccessibilityProperties |
getAccessibilityProperties() |
Cell |
getCell(int row,
int column)
Returns a cell as specified by its location.
|
float |
getColumnWidth(int column)
Returns the column width for the specified column.
|
Table |
getFooter()
Gets the footer of the table.
|
Table |
getHeader()
Gets the header of the table.
|
ArrayList<Border> |
getLastRowBottomBorder()
Gets the markup properties of the bottom border of the (current) last row.
|
int |
getNumberOfColumns()
Returns the number of columns.
|
int |
getNumberOfRows()
Returns the number of rows.
|
IRenderer |
getRenderer()
Gets a table renderer for this element.
|
PdfName |
getRole() |
protected List<Table.RowRange> |
getRowGroups() |
boolean |
isComplete()
Checks whether an element has already been marked as complete.
|
boolean |
isSkipFirstHeader()
Tells you if the first header needs to be skipped (for instance if the
header says "continued from the previous page").
|
boolean |
isSkipLastFooter()
Tells you if the last footer needs to be skipped (for instance if the
footer says "continued on the next page")
|
protected IRenderer |
makeNewRenderer() |
void |
setDocument(Document document)
Sets the document this element is bound to.
|
void |
setRole(PdfName role) |
Table |
setSkipFirstHeader(boolean skipFirstHeader)
Skips the printing of the first header.
|
Table |
setSkipLastFooter(boolean skipLastFooter)
Skips the printing of the last footer.
|
Table |
setWidth(UnitValue width)
Sets the full width of the table.
|
Table |
startNewRow()
Starts new row.
|
getDefaultProperty, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, isKeepTogether, setKeepTogether, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMargins, setMarginTop, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddings, setPaddingTop, setRotationAngle, setRotationAngle, setSpacingRatio, setVerticalAlignmentaddStyle, getProperty, hasProperty, isEmpty, propagateArtifactRoleToChildElements, setAction, setNextRenderer, setPageNumberdeleteOwnProperty, getHeight, getOwnProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getWidth, hasOwnProperty, setBackgroundColor, setBackgroundColor, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFontColor, setFontKerning, setFontScript, setFontSize, setHeight, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setWidth, setWidthPercent, setWordSpacingclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetNextRendererdeleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setPropertyprotected PdfName role
protected AccessibilityProperties tagProperties
public Table(float[] columnWidths,
boolean largeTable)
Table with the relative column widths.columnWidths - the relative column widthslargeTable - whether parts of the table will be written before all data is added.public Table(float[] columnWidths)
Table with the relative column widths.columnWidths - the relative column widthspublic Table(int numColumns,
boolean largeTable)
Table with numColumns columns.numColumns - the number of columnslargeTable - whether parts of the table will be written before all data is added.public Table(int numColumns)
Table with numColumns columns.numColumns - the number of columnspublic Table setWidth(UnitValue width)
setWidth in class ElementPropertyContainer<Table>width - the full width of the table.public float getColumnWidth(int column)
column - index of the columnpublic int getNumberOfColumns()
public int getNumberOfRows()
public Table addHeaderCell(Cell headerCell)
setSkipFirstHeader(boolean).headerCell - a header cell to be addedpublic <T extends IElement> Table addHeaderCell(BlockElement<T> blockElement)
setSkipFirstHeader(boolean).blockElement - an element to be added to a header cellpublic Table addHeaderCell(Image image)
setSkipFirstHeader(boolean).image - an element to be added to a header cellpublic Table addHeaderCell(String content)
setSkipFirstHeader(boolean).content - a string to be added to a header cellpublic Table getHeader()
null, if addHeaderCell(Cell) hasn't been called.public Table addFooterCell(Cell footerCell)
setSkipLastFooter(boolean).footerCell - a footer cellpublic <T extends IElement> Table addFooterCell(BlockElement<T> blockElement)
setSkipLastFooter(boolean).blockElement - an element to be added to a footer cellpublic Table addFooterCell(Image image)
setSkipLastFooter(boolean).image - an image to be added to a footer cellpublic Table addFooterCell(String content)
setSkipLastFooter(boolean).content - a content string to be added to a footer cellpublic Table getFooter()
null, if addFooterCell(Cell) hasn't been called.public boolean isSkipFirstHeader()
public boolean isSkipLastFooter()
public Table setSkipFirstHeader(boolean skipFirstHeader)
skipFirstHeader - New value of property skipFirstHeader.public Table setSkipLastFooter(boolean skipLastFooter)
skipLastFooter - New value of property skipLastFooter.public Table startNewRow()
public Table addCell(Cell cell)
cell - Cell to add.public <T extends IElement> Table addCell(BlockElement<T> blockElement)
blockElement - a blockElement to add to the cell and then to the tablepublic Table addCell(Image image)
image - an image to add to the cell and then to the tablepublic Table addCell(String content)
content - a string to add to the cell and then to the tablepublic Cell getCell(int row, int column)
null is returned.row - the row of the cell. indexes are zero-basedcolumn - the column of the cell. indexes are zero-basedpublic IRenderer createRendererSubTree()
getRenderer(), the renderer returned by this method should contain all the child
renderers for children of the current element.createRendererSubTree in interface IElementcreateRendererSubTree in class AbstractElement<Table>TableRenderer subtree for this elementprotected IRenderer makeNewRenderer()
makeNewRenderer in class AbstractElement<Table>public IRenderer getRenderer()
AbstractElement.setNextRenderer(IRenderer) method call.getRenderer in interface IElementgetRenderer in class AbstractElement<Table>public boolean isComplete()
ILargeElementisComplete in interface ILargeElementpublic void complete()
setSkipLastFooter(boolean) method set to true,
and in case of large table on flush() we do not know if any more content will be added,
so we might not place the content in the bottom of the page where it would fit, but instead add a footer, and
place that content in the start of the page. Technically such result would look all right, but it would be
more concise if we placed the content in the bottom and did not start new page. For such cases to be
renderered more accurately, one can call complete() when some content is still there and not flushed.complete in interface ILargeElementpublic void flush()
flush in interface ILargeElementpublic void flushContent()
flushContent in interface ILargeElementpublic void setDocument(Document document)
ILargeElementsetDocument in interface ILargeElementdocument - the documentpublic ArrayList<Border> getLastRowBottomBorder()
Border objectspublic PdfName getRole()
getRole in interface IAccessibleElementpublic void setRole(PdfName role)
setRole in interface IAccessibleElementpublic AccessibilityProperties getAccessibilityProperties()
getAccessibilityProperties in interface IAccessibleElementprotected void calculateWidths()
protected List<Table.RowRange> getRowGroups()
Copyright © 1998–2016 iText Group NV. All rights reserved.