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, styles
properties
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 |
---|---|
|
addCell(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.
|
|
addFooterCell(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.
|
|
addHeaderCell(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()
Gets the accessibility properties .
|
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()
Gets the element's role.
|
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)
Sets the element's 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.
|
getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, isKeepTogether, isKeepWithNext, setKeepTogether, setKeepWithNext, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMargins, setMarginTop, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddings, setPaddingTop, setRotationAngle, setRotationAngle, setSpacingRatio, setVerticalAlignment
addStyle, getProperty, hasProperty, isEmpty, propagateArtifactRoleToChildElements, setAction, setNextRenderer, setPageNumber
deleteOwnProperty, getDefaultProperty, 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, setWordSpacing
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setNextRenderer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
protected PdfName role
protected AccessibilityProperties tagProperties
public Table(float[] columnWidths, boolean largeTable)
Table
with the relative column widths.
columnWidths
- the relative column widths
largeTable
- 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 widths
public Table(int numColumns, boolean largeTable)
Table
with numColumns
columns.
numColumns
- the number of columns
largeTable
- 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 columns
public 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 column
public int getNumberOfColumns()
public int getNumberOfRows()
public Table addHeaderCell(Cell headerCell)
setSkipFirstHeader(boolean)
.
headerCell
- a header cell to be added
publicIElement> Table addHeaderCell(BlockElement blockElement)
setSkipFirstHeader(boolean)
.
blockElement
- an element to be added to a header cell
public Table addHeaderCell(Image image)
setSkipFirstHeader(boolean)
.
image
- an element to be added to a header cell
public Table addHeaderCell(String content)
setSkipFirstHeader(boolean)
.
content
- a string to be added to a header cell
public Table getHeader()
null
, if addHeaderCell(Cell)
hasn't been called.
public Table addFooterCell(Cell footerCell)
setSkipLastFooter(boolean)
.
footerCell
- a footer cell
publicIElement> Table addFooterCell(BlockElement blockElement)
setSkipLastFooter(boolean)
.
blockElement
- an element to be added to a footer cell
public Table addFooterCell(Image image)
setSkipLastFooter(boolean)
.
image
- an image to be added to a footer cell
public Table addFooterCell(String content)
setSkipLastFooter(boolean)
.
content
- a content string to be added to a footer cell
public 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.
publicIElement> Table addCell(BlockElement blockElement)
blockElement
- a blockElement to add to the cell and then to the table
public Table addCell(Image image)
image
- an image to add to the cell and then to the table
public Table addCell(String content)
content
- a string to add to the cell and then to the table
public Cell getCell(int row, int column)
null
is returned.
row
- the row of the cell. indexes are zero-based
column
- the column of the cell. indexes are zero-based
public IRenderer createRendererSubTree()
getRenderer()
, the renderer returned by this method should contain all the child renderers for children of the current element.
createRendererSubTree
in interface IElement
createRendererSubTree
in class AbstractElement<Table>
TableRenderer
subtree for this element
protected IRenderer makeNewRenderer()
makeNewRenderer
in class AbstractElement<Table>
public IRenderer getRenderer()
AbstractElement.setNextRenderer(IRenderer)
method call.
getRenderer
in interface IElement
getRenderer
in class AbstractElement<Table>
public boolean isComplete()
ILargeElement
isComplete
in interface ILargeElement
public 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 ILargeElement
public void flush()
flush
in interface ILargeElement
public void flushContent()
flushContent
in interface ILargeElement
public void setDocument(Document document)
ILargeElement
setDocument
in interface ILargeElement
document
- the document
public ArrayList<Border> getLastRowBottomBorder()
Border
objects
public PdfName getRole()
IAccessibleElement
getRole
in interface IAccessibleElement
PdfName
containing the name of the role
public void setRole(PdfName role)
IAccessibleElement
setRole
in interface IAccessibleElement
role
- the new role which the IAccessibleElement
should take
public AccessibilityProperties getAccessibilityProperties()
IAccessibleElement
accessibility properties
.
getAccessibilityProperties
in interface IAccessibleElement
protected void calculateWidths()
protected List<Table.RowRange> getRowGroups()
Copyright © 1998–2016 iText Group NV. All rights reserved.