HiraokaHyperTools.iTextSharp-LGPL  0.2.5
iTextSharp.text.pdf.PdfPTable Class Reference
Inheritance diagram for iTextSharp.text.pdf.PdfPTable:
iTextSharp.text.ILargeElement iTextSharp.text.IElement

Public Member Functions

 PdfPTable (float[] relativeWidths)
 
 PdfPTable (int numColumns)
 
 PdfPTable (PdfPTable table)
 
void SetWidths (float[] relativeWidths)
 
void SetWidths (int[] relativeWidths)
 
void SetTotalWidth (float[] columnWidth)
 
void SetWidthPercentage (float[] columnWidth, Rectangle pageSize)
 
float CalculateHeights (bool firsttime)
 
void CalculateHeightsFast ()
 
void AddCell (PdfPCell cell)
 
void AddCell (String text)
 
void AddCell (PdfPTable table)
 
void AddCell (Image image)
 
void AddCell (Phrase phrase)
 
float WriteSelectedRows (int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases)
 
float WriteSelectedRows (int colStart, int colEnd, int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases)
 
float WriteSelectedRows (int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte canvas)
 
float WriteSelectedRows (int colStart, int colEnd, int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte canvas)
 
float GetRowHeight (int idx)
 
float GetRowHeight (int idx, bool firsttime)
 
float GetRowspanHeight (int rowIndex, int cellIndex)
 
bool DeleteRow (int rowNumber)
 
bool DeleteLastRow ()
 
void DeleteBodyRows ()
 
bool IsContent ()
 
bool IsNestable ()
 
bool Process (IElementListener listener)
 
PdfPRow GetRow (int idx)
 
ArrayList GetRows (int start, int end)
 
void CompleteRow ()
 
void FlushContent ()
 
- Public Member Functions inherited from iTextSharp.text.IElement
string ToString ()
 Gets the content of the text element. More...
 

Static Public Member Functions

static PdfPTable ShallowCopy (PdfPTable table)
 
static PdfContentByte[] BeginWritingRows (PdfContentByte canvas)
 
static void EndWritingRows (PdfContentByte[] canvases)
 

Static Public Attributes

const int BASECANVAS = 0
 
const int BACKGROUNDCANVAS = 1
 
const int LINECANVAS = 2
 
const int TEXTCANVAS = 3
 

Protected Member Functions

 PdfPTable ()
 
PdfPRow AdjustCellsInRow (int start, int end)
 

Protected Attributes

ArrayList rows = new ArrayList()
 
float totalHeight = 0
 
PdfPCell[] currentRow
 
int currentRowIdx = 0
 
PdfPCell defaultCell = new PdfPCell((Phrase)null)
 
float totalWidth = 0
 
float[] relativeWidths
 
float[] absoluteWidths
 
IPdfPTableEvent tableEvent
 
int headerRows
 
float widthPercentage = 80
 
bool isColspan = false
 
int runDirection = PdfWriter.RUN_DIRECTION_DEFAULT
 
float spacingBefore
 
float spacingAfter
 
bool complete = true
 
bool rowCompleted = true
 

Properties

float TotalWidth [get, set]
 
PdfPCell DefaultCell [get]
 
int Size [get]
 
float TotalHeight [get]
 
float HeaderHeight [get]
 
float FooterHeight [get]
 
int NumberOfColumns [get]
 
int HeaderRows [get, set]
 
int FooterRows [get, set]
 
ArrayList Chunks [get]
 
int Type [get]
 
float WidthPercentage [get, set]
 
int HorizontalAlignment [get, set]
 
ArrayList Rows [get]
 
IPdfPTableEvent TableEvent [get, set]
 
float[] AbsoluteWidths [get]
 
bool SkipFirstHeader [get, set]
 
bool SkipLastFooter [get, set]
 
int RunDirection [get, set]
 
bool LockedWidth [get, set]
 
bool SplitRows [get, set]
 
float SpacingBefore [get, set]
 
float SpacingAfter [get, set]
 
bool ExtendLastRow [get, set]
 
bool HeadersInEvent [get, set]
 
bool SplitLate [get, set]
 
bool KeepTogether [get, set]
 
bool ElementComplete [get, set]
 
- Properties inherited from iTextSharp.text.ILargeElement
bool ElementComplete [get, set]
 
- Properties inherited from iTextSharp.text.IElement
int Type [get]
 Gets the type of the text element. More...
 
ArrayList Chunks [get]
 Gets all the chunks in this element. More...
 

Detailed Description

This is a table that can be put at an absolute position but can also be added to the document as the class 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.

Author
Paulo Soares (psoar.nosp@m.es@c.nosp@m.onsis.nosp@m.te.p.nosp@m.t)

Constructor & Destructor Documentation

◆ PdfPTable() [1/4]

iTextSharp.text.pdf.PdfPTable.PdfPTable ( )
protected

◆ PdfPTable() [2/4]

iTextSharp.text.pdf.PdfPTable.PdfPTable ( float[]  relativeWidths)

Constructs a PdfPTable with the relative column widths.

Parameters
relativeWidthsthe relative column widths

◆ PdfPTable() [3/4]

iTextSharp.text.pdf.PdfPTable.PdfPTable ( int  numColumns)

Constructs a PdfPTable with numColumns columns.

Parameters
numColumnsthe number of columns

◆ PdfPTable() [4/4]

iTextSharp.text.pdf.PdfPTable.PdfPTable ( PdfPTable  table)

Constructs a copy of a PdfPTable.

Parameters
tablethe PdfPTable to be copied

Member Function Documentation

◆ AddCell() [1/5]

void iTextSharp.text.pdf.PdfPTable.AddCell ( Image  image)

Adds an Image as Cell.

Parameters
imagethe Image to add to the table. This image will fit in the cell

◆ AddCell() [2/5]

void iTextSharp.text.pdf.PdfPTable.AddCell ( PdfPCell  cell)

Adds a cell element.

Parameters
cellthe cell element

◆ AddCell() [3/5]

void iTextSharp.text.pdf.PdfPTable.AddCell ( PdfPTable  table)

Adds a nested table.

Parameters
tablethe table to be added to the cell

◆ AddCell() [4/5]

void iTextSharp.text.pdf.PdfPTable.AddCell ( Phrase  phrase)

Adds a cell element.

Parameters
phrasethe Phrase to be added to the cell

◆ AddCell() [5/5]

void iTextSharp.text.pdf.PdfPTable.AddCell ( String  text)

Adds a cell element.

Parameters
textthe text for the cell

◆ AdjustCellsInRow()

PdfPRow iTextSharp.text.pdf.PdfPTable.AdjustCellsInRow ( int  start,
int  end 
)
protected

Calculates the extra height needed in a row because of rowspans.

Parameters
startthe index of the start row (the one to adjust)
endthe index of the end row on the page
Since
2.1.6

◆ BeginWritingRows()

static PdfContentByte [] iTextSharp.text.pdf.PdfPTable.BeginWritingRows ( PdfContentByte  canvas)
static

Gets and initializes the 4 layers where the table is written to. The text or graphics are added to one of the 4 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
canvasthe PdfContentByte where the rows will be written to
Returns
an array of 4 PdfContentByte
See also
#writeSelectedRows(int, int, float, float, PdfContentByte[])

◆ CalculateHeights()

float iTextSharp.text.pdf.PdfPTable.CalculateHeights ( bool  firsttime)

Calculates the heights of the table.

Parameters
firsttimeif true, the heights of the rows will be recalculated. This takes time; normally the heights of the rows are already calcultated, so in most cases, it's save to use false as parameter.
Returns
the total height of the table. Note that it will be 0 if you didn't specify the width of the table with SetTotalWidth().
Since
2.1.5 added a parameter and a return type to an existing method, and made it public

◆ CalculateHeightsFast()

void iTextSharp.text.pdf.PdfPTable.CalculateHeightsFast ( )

Calculates the heights of the table.

◆ CompleteRow()

void iTextSharp.text.pdf.PdfPTable.CompleteRow ( )

Completes the current row with the default cell. An incomplete row will be dropped but calling this method will make sure that it will be present in the table.

◆ DeleteBodyRows()

void iTextSharp.text.pdf.PdfPTable.DeleteBodyRows ( )

Removes all of the rows except headers

◆ DeleteLastRow()

bool iTextSharp.text.pdf.PdfPTable.DeleteLastRow ( )

Deletes the last row in the table.

Returns
true if the last row was deleted

◆ DeleteRow()

bool iTextSharp.text.pdf.PdfPTable.DeleteRow ( int  rowNumber)

Deletes a row from the table.

Parameters
rowNumberthe row to be deleted
Returns
true if the row was deleted

◆ EndWritingRows()

static void iTextSharp.text.pdf.PdfPTable.EndWritingRows ( PdfContentByte[]  canvases)
static

Finishes writing the table.

Parameters
canvasesthe array returned by beginWritingRows()

◆ FlushContent()

void iTextSharp.text.pdf.PdfPTable.FlushContent ( )
Since
iText 2.0.8
See also
com.lowagie.text.LargeElement::flushContent()

Implements iTextSharp.text.ILargeElement.

◆ GetRow()

PdfPRow iTextSharp.text.pdf.PdfPTable.GetRow ( int  idx)

Gets a row with a given index (added by Jin-Hsia Yang).

Parameters
idx
Returns
the row at position idx

◆ GetRowHeight() [1/2]

float iTextSharp.text.pdf.PdfPTable.GetRowHeight ( int  idx)

Gets the height of a particular row.

Parameters
idxthe row index (starts at 0)
Returns
the height of a particular row

◆ GetRowHeight() [2/2]

float iTextSharp.text.pdf.PdfPTable.GetRowHeight ( int  idx,
bool  firsttime 
)

Gets the height of a particular row.

Parameters
idxthe row index (starts at 0)
firsttimeis this the first time the row heigh is calculated?
Returns
the height of a particular row
Since
3.0.0

◆ GetRows()

ArrayList iTextSharp.text.pdf.PdfPTable.GetRows ( int  start,
int  end 
)

Gets an arraylist with a selection of rows.

Parameters
startthe first row in the selection
endthe first row that isn't part of the selection
Returns
a selection of rows
Since
2.1.6

◆ GetRowspanHeight()

float iTextSharp.text.pdf.PdfPTable.GetRowspanHeight ( int  rowIndex,
int  cellIndex 
)

Gets the maximum height of a cell in a particular row (will only be different from getRowHeight is one of the cells in the row has a rowspan > 1).

Parameters
rowIndexthe row index
cellIndexthe cell index
Returns
the height of a particular row including rowspan
Since
2.1.6

◆ IsContent()

bool iTextSharp.text.pdf.PdfPTable.IsContent ( )
See also
com.lowagie.text.Element::isContent()
Since
iText 2.0.8

Implements iTextSharp.text.IElement.

◆ IsNestable()

bool iTextSharp.text.pdf.PdfPTable.IsNestable ( )
See also
com.lowagie.text.Element::isNestable()
Since
iText 2.0.8

Implements iTextSharp.text.IElement.

◆ Process()

bool iTextSharp.text.pdf.PdfPTable.Process ( IElementListener  listener)

Processes the element by adding it (or the different parts) to an ElementListener.

Parameters
listeneran ElementListener
Returns
true if the element was processed successfully

Implements iTextSharp.text.IElement.

◆ SetTotalWidth()

void iTextSharp.text.pdf.PdfPTable.SetTotalWidth ( float[]  columnWidth)

Sets the full width of the table from the absolute column width.

Parameters
columnWidththe absolute width of each column
Exceptions
DocumentExceptionif the number of widths is different than the number of columns

◆ SetWidthPercentage()

void iTextSharp.text.pdf.PdfPTable.SetWidthPercentage ( float[]  columnWidth,
Rectangle  pageSize 
)

Sets the percentage width of the table from the absolute column width.

Parameters
columnWidththe absolute width of each column
pageSizethe page size
Exceptions
DocumentException

◆ SetWidths() [1/2]

void iTextSharp.text.pdf.PdfPTable.SetWidths ( float[]  relativeWidths)

Sets the relative widths of the table.

Parameters
relativeWidthsthe relative widths of the table.
Exceptions
DocumentExceptionif the number of widths is different than the number of columns

◆ SetWidths() [2/2]

void iTextSharp.text.pdf.PdfPTable.SetWidths ( int[]  relativeWidths)

Sets the relative widths of the table.

Parameters
relativeWidthsthe relative widths of the table.
Exceptions
DocumentExceptionif the number of widths is different than the number of columns

◆ ShallowCopy()

static PdfPTable iTextSharp.text.pdf.PdfPTable.ShallowCopy ( PdfPTable  table)
static

Makes a shallow copy of a table (format without content).

Parameters
table
Returns
a shallow copy of the table

◆ WriteSelectedRows() [1/4]

float iTextSharp.text.pdf.PdfPTable.WriteSelectedRows ( int  colStart,
int  colEnd,
int  rowStart,
int  rowEnd,
float  xPos,
float  yPos,
PdfContentByte  canvas 
)

Writes the selected rows to the document. This method clips the columns; this is only important if there are columns with colspan at boundaries.

The table event is only fired for complete rows.

Parameters
colStartthe first column to be written, zero index
colEndthe last column to be written + 1. If it is -1 all the
rowStartthe first row to be written, zero index
rowEndthe last row to be written + 1. If it is -1 all the rows to the end are written
xPosthe x write coodinate
yPosthe y write coodinate
canvasthe PdfContentByte where the rows will be written to
Returns
the y coordinate position of the bottom of the last row

◆ WriteSelectedRows() [2/4]

float iTextSharp.text.pdf.PdfPTable.WriteSelectedRows ( int  colStart,
int  colEnd,
int  rowStart,
int  rowEnd,
float  xPos,
float  yPos,
PdfContentByte[]  canvases 
)

Writes the selected rows and columns to the document. This method does not clip the columns; this is only important if there are columns with colspan at boundaries.

canvases is obtained from beginWritingRows().

The table event is only fired for complete rows.

Parameters
colStartthe first column to be written, zero index
colEndthe last column to be written + 1. If it is -1 all the columns to the end are written
rowStartthe first row to be written, zero index
rowEndthe last row to be written + 1. If it is -1 all the rows to the end are written
xPosthe x write coodinate
yPosthe y write coodinate
canvasesan array of 4 PdfContentByte obtained from beginWrittingRows()
Returns
the y coordinate position of the bottom of the last row
See also
#beginWritingRows(com.lowagie.text.pdf.PdfContentByte)

◆ WriteSelectedRows() [3/4]

float iTextSharp.text.pdf.PdfPTable.WriteSelectedRows ( int  rowStart,
int  rowEnd,
float  xPos,
float  yPos,
PdfContentByte  canvas 
)

Writes the selected rows to the document.

Parameters
rowStartthe first row to be written, zero index
rowEndthe last row to be written + 1. If it is -1 all the rows to the end are written
xPosthe x write coodinate
yPosthe y write coodinate
canvasthe PdfContentByte where the rows will be written to
Returns
the y coordinate position of the bottom of the last row

◆ WriteSelectedRows() [4/4]

float iTextSharp.text.pdf.PdfPTable.WriteSelectedRows ( int  rowStart,
int  rowEnd,
float  xPos,
float  yPos,
PdfContentByte[]  canvases 
)

Writes the selected rows to the document.

canvases is obtained from beginWritingRows().

Parameters
rowStartthe first row to be written, zero index
rowEndthe last row to be written + 1. If it is -1 all the rows to the end are written
xPosthe x write coodinate
yPosthe y write coodinate
canvasesan array of 4 PdfContentByte obtained from beginWrittingRows()
Returns
the y coordinate position of the bottom of the last row
See also
#beginWritingRows(com.lowagie.text.pdf.PdfContentByte)

Member Data Documentation

◆ absoluteWidths

float [] iTextSharp.text.pdf.PdfPTable.absoluteWidths
protected

◆ BACKGROUNDCANVAS

const int iTextSharp.text.pdf.PdfPTable.BACKGROUNDCANVAS = 1
static

The index of the duplicate PdfContentByte where the background will be drawn.

◆ BASECANVAS

const int iTextSharp.text.pdf.PdfPTable.BASECANVAS = 0
static

The index of the original PdfcontentByte.

◆ complete

bool iTextSharp.text.pdf.PdfPTable.complete = true
protected

Indicates if the PdfPTable is complete once added to the document.

Since
iText 2.0.8

◆ currentRow

PdfPCell [] iTextSharp.text.pdf.PdfPTable.currentRow
protected

◆ currentRowIdx

int iTextSharp.text.pdf.PdfPTable.currentRowIdx = 0
protected

◆ defaultCell

PdfPCell iTextSharp.text.pdf.PdfPTable.defaultCell = new PdfPCell((Phrase)null)
protected

◆ headerRows

int iTextSharp.text.pdf.PdfPTable.headerRows
protected

Holds value of property headerRows.

◆ isColspan

bool iTextSharp.text.pdf.PdfPTable.isColspan = false
protected

◆ LINECANVAS

const int iTextSharp.text.pdf.PdfPTable.LINECANVAS = 2
static

The index of the duplicate PdfContentByte where the border lines will be drawn.

◆ relativeWidths

float [] iTextSharp.text.pdf.PdfPTable.relativeWidths
protected

◆ rowCompleted

bool iTextSharp.text.pdf.PdfPTable.rowCompleted = true
protected

Keeps track of the completeness of the current row.

Since
2.1.6

◆ rows

ArrayList iTextSharp.text.pdf.PdfPTable.rows = new ArrayList()
protected

◆ runDirection

int iTextSharp.text.pdf.PdfPTable.runDirection = PdfWriter.RUN_DIRECTION_DEFAULT
protected

◆ spacingAfter

float iTextSharp.text.pdf.PdfPTable.spacingAfter
protected

The spacing after the table.

◆ spacingBefore

float iTextSharp.text.pdf.PdfPTable.spacingBefore
protected

The spacing before the table.

◆ tableEvent

IPdfPTableEvent iTextSharp.text.pdf.PdfPTable.tableEvent
protected

◆ TEXTCANVAS

const int iTextSharp.text.pdf.PdfPTable.TEXTCANVAS = 3
static

The index of the duplicate PdfContentByte where the text will be drawn.

◆ totalHeight

float iTextSharp.text.pdf.PdfPTable.totalHeight = 0
protected

◆ totalWidth

float iTextSharp.text.pdf.PdfPTable.totalWidth = 0
protected

◆ widthPercentage

float iTextSharp.text.pdf.PdfPTable.widthPercentage = 80
protected

Holds value of property widthPercentage.

Property Documentation

◆ AbsoluteWidths

float [] iTextSharp.text.pdf.PdfPTable.AbsoluteWidths
get

Gets the absolute sizes of each column width.

Returns
he absolute sizes of each column width

◆ Chunks

ArrayList iTextSharp.text.pdf.PdfPTable.Chunks
get

Gets all the chunks in this element.

Returns
an ArrayList

◆ DefaultCell

PdfPCell iTextSharp.text.pdf.PdfPTable.DefaultCell
get

Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell).

Returns
default PdfPCell

◆ ElementComplete

bool iTextSharp.text.pdf.PdfPTable.ElementComplete
getset
Since
iText 2.0.8
See also
com.lowagie.text.LargeElement::isComplete()

◆ ExtendLastRow

bool iTextSharp.text.pdf.PdfPTable.ExtendLastRow
getset

◆ FooterHeight

float iTextSharp.text.pdf.PdfPTable.FooterHeight
get

Gets the height of the rows that constitute the header as defined by setFooterRows().

Returns
the height of the rows that constitute the footer
Since
2.1.1

◆ FooterRows

int iTextSharp.text.pdf.PdfPTable.FooterRows
getset

◆ HeaderHeight

float iTextSharp.text.pdf.PdfPTable.HeaderHeight
get

Gets the height of the rows that constitute the header as defined by setHeaderRows().

Returns
the height of the rows that constitute the header and footer

◆ HeaderRows

int iTextSharp.text.pdf.PdfPTable.HeaderRows
getset

◆ HeadersInEvent

bool iTextSharp.text.pdf.PdfPTable.HeadersInEvent
getset

◆ HorizontalAlignment

int iTextSharp.text.pdf.PdfPTable.HorizontalAlignment
getset

◆ KeepTogether

bool iTextSharp.text.pdf.PdfPTable.KeepTogether
getset

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. The default is to split the table over multiple pages.

Parameters
p_KeepTogetherwhether to try to keep the table on one page

◆ LockedWidth

bool iTextSharp.text.pdf.PdfPTable.LockedWidth
getset

◆ NumberOfColumns

int iTextSharp.text.pdf.PdfPTable.NumberOfColumns
get

Returns the number of columns.

Returns
the number of columns.
Since
2.1.1

◆ Rows

ArrayList iTextSharp.text.pdf.PdfPTable.Rows
get

Gets an arraylist with all the rows in the table.

Returns
an arraylist

◆ RunDirection

int iTextSharp.text.pdf.PdfPTable.RunDirection
getset

◆ Size

int iTextSharp.text.pdf.PdfPTable.Size
get

Gets the number of rows in this table.

Returns
the number of rows in this table

◆ SkipFirstHeader

bool iTextSharp.text.pdf.PdfPTable.SkipFirstHeader
getset

◆ SkipLastFooter

bool iTextSharp.text.pdf.PdfPTable.SkipLastFooter
getset

Tells you if the last footer needs to be skipped (for instance if the footer says "continued on the next page")

Returns
Value of property skipLastFooter.
Since
2.1.6

◆ SpacingAfter

float iTextSharp.text.pdf.PdfPTable.SpacingAfter
getset

◆ SpacingBefore

float iTextSharp.text.pdf.PdfPTable.SpacingBefore
getset

◆ SplitLate

bool iTextSharp.text.pdf.PdfPTable.SplitLate
getset

◆ SplitRows

bool iTextSharp.text.pdf.PdfPTable.SplitRows
getset

◆ TableEvent

IPdfPTableEvent iTextSharp.text.pdf.PdfPTable.TableEvent
getset

◆ TotalHeight

float iTextSharp.text.pdf.PdfPTable.TotalHeight
get

Gets the total height of the table.

Returns
the total height of the table

◆ TotalWidth

float iTextSharp.text.pdf.PdfPTable.TotalWidth
getset

Gets the full width of the table.

Returns
the full width of the table

◆ Type

int iTextSharp.text.pdf.PdfPTable.Type
get

Gets the type of the text element.

Returns
a type

◆ WidthPercentage

float iTextSharp.text.pdf.PdfPTable.WidthPercentage
getset

The documentation for this class was generated from the following file: