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[] pointColumnWidths)
Constructs a
Table with the preferable column widths. |
Table(float[] columnWidths,
boolean largeTable)
Constructs a
Table with the preferable column widths. |
Table(int numColumns)
Deprecated.
in 7.1 each column will have undefined width.
Use another constructor to get predictable result.
|
Table(int numColumns,
boolean largeTable)
Deprecated.
in 7.1 each column will have undefined width.
Use another constructor to get predictable result.
|
Table(UnitValue[] columnWidths)
Constructs a
Table with the preferable column widths. |
Table(UnitValue[] columnWidths,
boolean largeTable)
Constructs a
Table with the preferable column widths. |
| 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()
Deprecated.
This method does nothing after implementation table column width algorithms.
|
void |
complete()
Indicates that all the desired content has been added to this large element and no more content will be added.
|
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.
|
UnitValue |
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.
|
List<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() |
Table |
setAutoLayout()
Set auto layout.
|
void |
setDocument(Document document)
Sets the document this element is bound to.
|
Table |
setExtendBottomRow(boolean isExtended) |
Table |
setExtendBottomRowOnSplit(boolean isExtended) |
Table |
setFixedLayout()
Set fixed layout.
|
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 |
startNewRow()
Starts new row.
|
Table |
useAllAvailableWidth()
Set
Property.WIDTH = 100%. |
getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, isKeepTogether, isKeepWithNext, setHeight, setKeepTogether, setKeepWithNext, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMargins, setMarginTop, setMaxHeight, setMinHeight, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddings, setPaddingTop, setRotationAngle, setRotationAngle, setSpacingRatio, setVerticalAlignmentaddStyle, getChildren, getProperty, hasProperty, isEmpty, propagateArtifactRoleToChildElements, setAction, setNextRenderer, setPageNumberdeleteOwnProperty, getDefaultProperty, getHeight, getOwnProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getWidth, hasOwnProperty, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFont, setFontColor, setFontColor, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setOpacity, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWidth, 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 preferable column widths.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().columnWidths - preferable column widths in points. Values must be greater than or equal to zero,
otherwise it will be interpreted as undefined.largeTable - whether parts of the table will be written before all data is added.
Note, large table does not support auto layout. Table width must be specified.setAutoLayout(),
setFixedLayout()public Table(UnitValue[] columnWidths, boolean largeTable)
Table with the preferable column widths.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().columnWidths - preferable column widths, points and/or percents. Values must be greater than or equal to zero,
otherwise it will be interpreted as undefined.largeTable - whether parts of the table will be written before all data is added.setAutoLayout(),
setFixedLayout()public Table(UnitValue[] columnWidths)
Table with the preferable column widths.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().columnWidths - preferable column widths, points and/or percents. Values must be greater than or equal to zero,
otherwise it will be interpreted as undefined.setAutoLayout(),
setFixedLayout()public Table(float[] pointColumnWidths)
Table with the preferable column widths.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().pointColumnWidths - preferable column widths in points. Values must be greater than or equal to zero,
otherwise it will be interpreted as undefined.setAutoLayout(),
setFixedLayout()@Deprecated public Table(int numColumns, boolean largeTable)
Table with specified number of columns. Each column will get equal percent width,
the final column widths depend on selected table layout. 100% table width set implicitly for backward compatibility.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().numColumns - the number of columns, each column will have equal percent width.largeTable - whether parts of the table will be written before all data is added.
Note, large table does not support auto layout. Table width must be specified.setAutoLayout(),
setFixedLayout()@Deprecated public Table(int numColumns)
Table with specified number of columns. Each column will get equal percent width,
the final column widths depend on selected table layout. 100% table width set implicitly for backward compatibility.
columnWidths is <colgroup>'s widths.
For more information see setAutoLayout() and setFixedLayout().numColumns - the number of columns, each column will have equal percent width.setAutoLayout(),
setFixedLayout()public Table setFixedLayout()
table-layout:fixed CSS property.
Note, the table must have width property, otherwise auto layout will be used.
Algorithm description
<colgroup> element in HTML.
width/colspan.
remainWidth/colspan to each column.
public Table setAutoLayout()
table-layout:fixed CSS property. public Table useAllAvailableWidth()
Property.WIDTH = 100%.public UnitValue 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 Table setSkipFirstHeader(boolean skipFirstHeader)
skipFirstHeader - New value of property skipFirstHeader.public boolean isSkipLastFooter()
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 List<Border> getLastRowBottomBorder()
Border objectspublic PdfName getRole()
getRole in interface IAccessibleElementpublic void setRole(PdfName role)
setRole in interface IAccessibleElementpublic Table setExtendBottomRow(boolean isExtended)
public Table setExtendBottomRowOnSplit(boolean isExtended)
public AccessibilityProperties getAccessibilityProperties()
getAccessibilityProperties in interface IAccessibleElement@Deprecated protected void calculateWidths()
protected List<Table.RowRange> getRowGroups()
Copyright © 1998–2017 iText Group NV. All rights reserved.