com.lowagie.text.pdf
public class PdfPTable extends Object implements LargeElement
Table
.
In the last case when crossing pages the table always break at full rows; if a
row is bigger than the page it is dropped silently to avoid infinite loops.
A PdfPTableEvent can be associated to the table to do custom drawing when the table is rendered.
Field Summary | |
---|---|
protected float[] | absoluteWidths |
static int | BACKGROUNDCANVAS The index of the duplicate PdfContentByte where the background will be drawn. |
static int | BASECANVAS The index of the original PdfcontentByte . |
protected boolean | complete
Indicates if the PdfPTable is complete once added to the document. |
protected PdfPCell[] | currentRow |
protected int | currentRowIdx |
protected PdfPCell | defaultCell |
boolean | extendLastRow
Holds value of property extendLastRow. |
int | footerRows
Holds value of property footerRows. |
protected int | headerRows Holds value of property headerRows. |
boolean | headersInEvent
Holds value of property headersInEvent. |
int | horizontalAlignment Holds value of property horizontalAlignment. |
protected boolean | isColspan |
boolean | keepTogether
Defines if the table should be kept
on one page if possible |
boolean | lockedWidth
Holds value of property lockedWidth. |
static int | LINECANVAS The index of the duplicate PdfContentByte where the border lines will be drawn. |
protected float[] | relativeWidths |
protected ArrayList | rows |
protected int | runDirection |
boolean | skipFirstHeader Holds value of property skipFirstHeader. |
protected float | spacingAfter The spacing after the table. |
protected float | spacingBefore The spacing before the table. |
boolean | splitLate
Holds value of property splitLate. |
boolean | splitRows
Holds value of property splitRows. |
protected PdfPTableEvent | tableEvent |
protected float | totalHeight |
protected float | totalWidth |
static int | TEXTCANVAS The index of the duplicate PdfContentByte where the text will be drawn. |
protected float | widthPercentage Holds value of property widthPercentage. |
Constructor Summary | |
---|---|
protected | PdfPTable() |
PdfPTable(float[] relativeWidths) Constructs a PdfPTable with the relative column widths. | |
PdfPTable(int numColumns) Constructs a PdfPTable with numColumns columns. | |
PdfPTable(PdfPTable table) Constructs a copy of a PdfPTable . |
Method Summary | |
---|---|
void | addCell(PdfPCell cell) Adds a cell element. |
void | addCell(String text) Adds a cell element. |
void | addCell(PdfPTable table)
Adds a nested table. |
void | addCell(Image image)
Adds an Image as Cell. |
void | addCell(Phrase phrase)
Adds a cell element. |
static PdfContentByte[] | beginWritingRows(PdfContentByte canvas) Gets and initializes the 4 layers where the table is written to. |
void | calculateHeights() |
void | calculateHeightsFast()
Calculates the heights of the table. |
void | calculateWidths() |
void | completeRow()
Completes the current row with the default cell. |
void | copyFormat(PdfPTable sourceTable)
Copies the format of the sourceTable without copying the content. |
void | deleteBodyRows()
Removes all of the rows except headers |
boolean | deleteLastRow() Deletes the last row in the table. |
boolean | deleteRow(int rowNumber) Deletes a row from the table. |
static void | endWritingRows(PdfContentByte[] canvases) Finishes writing the table. |
void | flushContent() |
float[] | getAbsoluteWidths() Gets the absolute sizes of each column width. |
ArrayList | getChunks()
Gets all the chunks in this element.
|
PdfPCell | getDefaultCell() Gets the default PdfPCell that will be used as
reference for all the addCell methods except
addCell(PdfPCell) . |
float[][] | getEventWidths(float xPos, int firstRow, int lastRow, boolean includeHeaders) |
float | getFooterHeight() Gets the height of the rows that constitute the header as defined by
setFooterRows() . |
int | getFooterRows()
Gets the number of rows in the footer. |
float | getHeaderHeight() Gets the height of the rows that constitute the header as defined by
setHeaderRows() . |
int | getHeaderRows() Gets the number of the rows that constitute the header. |
int | getHorizontalAlignment() Gets the horizontal alignment of the table relative to the page. |
boolean | getKeepTogether() |
int | getNumberOfColumns() Returns the number of columns. |
PdfPRow | getRow(int idx)
Gets a row with a given index
(added by Jin-Hsia Yang). |
float | getRowHeight(int idx) Gets the height of a particular row. |
ArrayList | getRows()
Gets an arraylist with all the rows in the table. |
int | getRunDirection()
Returns the run direction of the contents in the table. |
PdfPTableEvent | getTableEvent() Gets the table event for this page. |
float | getTotalHeight() Gets the total height of the table. |
float | getTotalWidth() Gets the full width of the table. |
float | getWidthPercentage() Gets the width percentage that the table will occupy in the page. |
boolean | isComplete() |
boolean | isContent() |
boolean | isExtendLastRow()
Gets the value of the last row extension. |
boolean | isHeadersInEvent()
Gets the header status inclusion in PdfPTableEvent. |
boolean | isLockedWidth()
Getter for property lockedWidth. |
boolean | isNestable() |
boolean | isSkipFirstHeader() Getter for property skipFirstHeader. |
boolean | isSplitLate()
Gets the property splitLate. |
boolean | isSplitRows()
Gets the split value. |
boolean | process(ElementListener listener)
Processes the element by adding it (or the different parts) to an
ElementListener .
|
void | setComplete(boolean complete) |
void | setExtendLastRow(boolean extendLastRow)
When set the last row will be extended to fill all the remaining space to the
bottom boundary. |
void | setFooterRows(int footerRows)
Sets the number of rows to be used for the footer. |
void | setHeaderRows(int headerRows) Sets the number of the top rows that constitute the header.
|
void | setHeadersInEvent(boolean headersInEvent)
When set the PdfPTableEvent will include the headers. |
void | setHorizontalAlignment(int horizontalAlignment) Sets the horizontal alignment of the table relative to the page.
|
void | setKeepTogether(boolean p_KeepTogether)
If true the table will be kept on one page if it fits, by forcing a
new page if it doesn't fit on the current page. |
void | setLockedWidth(boolean lockedWidth)
Uses the value in setTotalWidth() in Document.add() . |
void | setRunDirection(int runDirection)
Sets the run direction of the contents of the table. |
void | setSkipFirstHeader(boolean skipFirstHeader) Skips the printing of the first header. |
void | setSpacingAfter(float spacing)
Sets the spacing after this table.
|
void | setSpacingBefore(float spacing)
Sets the spacing before this table.
|
void | setSplitLate(boolean splitLate)
If true the row will only split if it's the first one in an empty page.
|
void | setSplitRows(boolean splitRows)
When set the rows that won't fit in the page will be split.
|
void | setTableEvent(PdfPTableEvent event) Sets the table event for this table. |
void | setTotalWidth(float totalWidth) Sets the full width of the table. |
void | setTotalWidth(float[] columnWidth) Sets the full width of the table from the absolute column width. |
void | setWidthPercentage(float[] columnWidth, Rectangle pageSize) Sets the percentage width of the table from the absolute column width. |
void | setWidthPercentage(float widthPercentage) Sets the width percentage that the table will occupy in the page. |
void | setWidths(float[] relativeWidths) Sets the relative widths of the table. |
void | setWidths(int[] relativeWidths) Sets the relative widths of the table. |
static PdfPTable | shallowCopy(PdfPTable table)
Makes a shallow copy of a table (format without content). |
int | size() Gets the number of rows in this table. |
float | spacingAfter()
Gets the spacing after this table.
|
float | spacingBefore()
Gets the spacing before this table.
|
int | type()
Gets the type of the text element.
|
float | writeSelectedRows(int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases)
Writes the selected rows to the document.
|
float | writeSelectedRows(int colStart, int colEnd, int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases) Writes the selected rows and columns to the document.
|
float | writeSelectedRows(int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte canvas)
Writes the selected rows to the document.
|
float | writeSelectedRows(int colStart, int colEnd, int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte canvas)
Writes the selected rows to the document.
|
PdfContentByte
where the background will be drawn.PdfcontentByte
.Since: iText 2.0.8
PdfContentByte
where the border lines will be drawn.PdfContentByte
where the text will be drawn.PdfPTable
with the relative column widths.Parameters: relativeWidths the relative column widths
PdfPTable
with numColumns
columns.Parameters: numColumns the number of columns
PdfPTable
.Parameters: table the PdfPTable
to be copied
Parameters: cell the cell element
Parameters: text the text for the cell
Parameters: table the table to be added to the cell
Parameters: image the Image
to add to the table. This image will fit in the cell
Parameters: phrase the Phrase
to be added to the cell
PdfContentByte
returned with the following order:
PdfPtable.BASECANVAS
- the original PdfContentByte
. Anything placed here
will be under the table.
PdfPtable.BACKGROUNDCANVAS
- the layer where the background goes to.
PdfPtable.LINECANVAS
- the layer where the lines go to.
PdfPtable.TEXTCANVAS
- the layer where the text go to. Anything placed here
will be over the table.
The layers are placed in sequence on top of each other.
Parameters: canvas the PdfContentByte
where the rows will
be written to
Returns: an array of 4 PdfContentByte
Parameters: sourceTable
Returns: true
if the last row was deleted
Parameters: rowNumber the row to be deleted
Returns: true
if the row was deleted
Parameters: canvases the array returned by beginWritingRows()
Since: iText 2.0.8
See Also: flushContent
Returns: he absolute sizes of each column width
Returns: an ArrayList
PdfPCell
that will be used as
reference for all the addCell
methods except
addCell(PdfPCell)
.Returns: default PdfPCell
setFooterRows()
.Returns: the height of the rows that constitute the footer
Since: 2.1.1
Returns: the number of rows in the footer
setHeaderRows()
.Returns: the height of the rows that constitute the header and footer
Returns: the number of the rows that constitute the header
Returns: the horizontal alignment of the table relative to the page
Returns: the number of columns.
Since: 2.1.1
Parameters: idx
Returns: the row at position idx
Parameters: idx the row index (starts at 0)
Returns: the height of a particular row
Returns: an arraylist
Returns: One of the following values: PdfWriter.RUN_DIRECTION_DEFAULT, PdfWriter.RUN_DIRECTION_NO_BIDI, PdfWriter.RUN_DIRECTION_LTR or PdfWriter.RUN_DIRECTION_RTL.
Returns: the table event for this page
Returns: the total height of the table
Returns: the full width of the table
Returns: the width percentage that the table will occupy in the page
Since: iText 2.0.8
See Also: isComplete
Since: iText 2.0.8
See Also: isContent
Returns: true if the last row will extend; false otherwise
Returns: true if the headers are included; false otherwise
Returns: Value of property lockedWidth.
Since: iText 2.0.8
See Also: isNestable
Returns: Value of property skipFirstHeader.
Returns: the property splitLate
Returns: true to split; false otherwise
ElementListener
.
Parameters: listener an ElementListener
Returns: true
if the element was processed successfully
Since: iText 2.0.8
See Also: LargeElement
Parameters: extendLastRow true to extend the last row; false otherwise
table.setHeaderRows(3); table.setFooterRows(1);
Row 0 and 1 will be the header rows and row 2 will be the footer row.
Parameters: footerRows the number of rows to be used for the footer
Document
and the table crosses pages.Parameters: headerRows the number of the top rows that constitute the header
Parameters: headersInEvent true to include the headers; false otherwise
Parameters: horizontalAlignment the horizontal alignment of the table relative to the page
Parameters: p_KeepTogether whether to try to keep the table on one page
setTotalWidth()
in Document.add()
.Parameters: lockedWidth true
to use the value in setTotalWidth()
in Document.add()
Parameters: runDirection
Parameters: skipFirstHeader New value of property skipFirstHeader.
Parameters: spacing the new spacing
Parameters: spacing the new spacing
It's only meaningful if setSplitRows(true).
Parameters: splitLate the property value
true
by default.Parameters: splitRows true to split; false otherwise
Parameters: event the table event for this table
Parameters: totalWidth the full width of the table.
Parameters: columnWidth the absolute width of each column
Throws: DocumentException if the number of widths is different than the number of columns
Parameters: columnWidth the absolute width of each column pageSize the page size
Throws: DocumentException
Parameters: widthPercentage the width percentage that the table will occupy in the page
Parameters: relativeWidths the relative widths of the table.
Throws: DocumentException if the number of widths is different than the number of columns
Parameters: relativeWidths the relative widths of the table.
Throws: DocumentException if the number of widths is different than the number of columns
Parameters: table
Returns: a shallow copy of the table
Returns: the number of rows in this table
Returns: the spacing
Returns: the spacing
Returns: a type
canvases
is obtained from beginWritingRows()
.
Parameters: rowStart the first row to be written, zero index rowEnd the last row to be written + 1. If it is -1 all the
rows to the end are written xPos the x write coordinate yPos the y write coordinate canvases an array of 4 PdfContentByte
obtained from
beginWrittingRows()
Returns: the y coordinate position of the bottom of the last row
See Also: beginWritingRows
canvases
is obtained from beginWritingRows()
.
The table event is only fired for complete rows.
Parameters: colStart the first column to be written, zero index colEnd the last column to be written + 1. If it is -1 all the
columns to the end are written rowStart the first row to be written, zero index rowEnd the last row to be written + 1. If it is -1 all the
rows to the end are written xPos the x write coordinate yPos the y write coordinate canvases an array of 4 PdfContentByte
obtained from
beginWrittingRows()
Returns: the y coordinate position of the bottom of the last row
See Also: beginWritingRows
Parameters: rowStart the first row to be written, zero index rowEnd the last row to be written + 1. If it is -1 all the
rows to the end are written xPos the x write coordinate yPos the y write coordinate canvas the PdfContentByte
where the rows will
be written to
Returns: the y coordinate position of the bottom of the last row
The table event is only fired for complete rows.
Parameters: colStart the first column to be written, zero index colEnd the last column to be written + 1. If it is -1 all the rowStart the first row to be written, zero index rowEnd the last row to be written + 1. If it is -1 all the
rows to the end are written xPos the x write coordinate yPos the y write coordinate canvas the PdfContentByte
where the rows will
be written to
Returns: the y coordinate position of the bottom of the last row