com.itextpdf.text.pdf
Class PdfPRow

java.lang.Object
  extended by com.itextpdf.text.pdf.PdfPRow
All Implemented Interfaces:
IAccessibleElement

public class PdfPRow
extends Object
implements IAccessibleElement

A row in a PdfPTable.

Author:
Paulo Soares

Field Summary
protected  HashMap<PdfName,PdfObject> accessibleAttributes
           
static float BOTTOM_LIMIT
          the bottom limit (bottom right y)
protected  boolean calculated
           
protected  PdfPCell[] cells
           
protected  float[] extraHeights
          extra heights that needs to be added to a cell because of rowspans.
protected  UUID id
           
protected  float maxHeight
           
 boolean mayNotBreak
          True if the table may not break after this row.
static float RIGHT_LIMIT
          the right limit
protected  PdfName role
           
protected  float[] widths
           
 
Constructor Summary
PdfPRow(PdfPCell[] cells)
          Constructs a new PdfPRow with the cells in the array that was passed as a parameter.
PdfPRow(PdfPCell[] cells, PdfPRow source)
           
PdfPRow(PdfPRow row)
          Makes a copy of an existing row.
 
Method Summary
protected  void calculateHeights()
          Calculates the heights of each cell in the row.
 void copyRowContent(PdfPTable table, int idx)
          Copies the content of a specific row in a table to this row.
 PdfObject getAccessibleAttribute(PdfName key)
          Get the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
 HashMap<PdfName,PdfObject> getAccessibleAttributes()
          Gets all the properties of accessible element.
 PdfPCell[] getCells()
          Returns the array of cells in the row.
 UUID getId()
           
 float getMaxHeights()
          Gets the maximum height of the row (i.e.
 PdfName getRole()
          Gets the role of the accessible element.
 boolean hasRowspan()
          Checks if a cell in the row has a rowspan greater than 1.
protected  void initExtraHeights()
          Initializes the extra heights array.
 boolean isCalculated()
          Checks if the dimensions of the columns were calculated.
 boolean isMayNotBreak()
          Getter for the mayNotbreak variable.
protected  void restoreCanvases(PdfContentByte[] canvases)
           
protected  void saveAndRotateCanvases(PdfContentByte[] canvases, float a, float b, float c, float d, float e, float f)
           
 void setAccessibleAttribute(PdfName key, PdfObject value)
          Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
static float setColumn(ColumnText ct, float left, float bottom, float right, float top)
           
 void setExtraHeight(int cell, float height)
          Sets an extra height for a cell.
 void setId(UUID id)
           
 void setMaxHeights(float maxHeight)
          Changes the maximum height of the row (to make it higher).
 void setMayNotBreak(boolean mayNotBreak)
          Setter for the mayNotBreak variable.
 void setRole(PdfName role)
          Sets the role of the accessiblee element.
 boolean setWidths(float[] widths)
          Sets the widths of the columns in the row.
 PdfPRow splitRow(PdfPTable table, int rowIndex, float new_height)
          Splits a row to newHeight.
 void writeBorderAndBackground(float xPos, float yPos, float currentMaxHeight, PdfPCell cell, PdfContentByte[] canvases)
          Writes the border and background of one cell in the row.
 void writeCells(int colStart, int colEnd, float xPos, float yPos, PdfContentByte[] canvases, boolean reusable)
          Writes a number of cells (not necessarily all cells).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mayNotBreak

public boolean mayNotBreak
True if the table may not break after this row.


BOTTOM_LIMIT

public static final float BOTTOM_LIMIT
the bottom limit (bottom right y)

See Also:
Constant Field Values

RIGHT_LIMIT

public static final float RIGHT_LIMIT
the right limit

Since:
2.1.5
See Also:
Constant Field Values

cells

protected PdfPCell[] cells

widths

protected float[] widths

extraHeights

protected float[] extraHeights
extra heights that needs to be added to a cell because of rowspans.

Since:
2.1.6

maxHeight

protected float maxHeight

calculated

protected boolean calculated

role

protected PdfName role

accessibleAttributes

protected HashMap<PdfName,PdfObject> accessibleAttributes

id

protected UUID id
Constructor Detail

PdfPRow

public PdfPRow(PdfPCell[] cells)
Constructs a new PdfPRow with the cells in the array that was passed as a parameter.

Parameters:
cells -

PdfPRow

public PdfPRow(PdfPCell[] cells,
               PdfPRow source)

PdfPRow

public PdfPRow(PdfPRow row)
Makes a copy of an existing row.

Parameters:
row -
Method Detail

setWidths

public boolean setWidths(float[] widths)
Sets the widths of the columns in the row.

Parameters:
widths -
Returns:
true if everything went right

initExtraHeights

protected void initExtraHeights()
Initializes the extra heights array.

Since:
2.1.6

setExtraHeight

public void setExtraHeight(int cell,
                           float height)
Sets an extra height for a cell.

Parameters:
cell - the index of the cell that needs an extra height
height - the extra height
Since:
2.1.6

calculateHeights

protected void calculateHeights()
Calculates the heights of each cell in the row.


setMayNotBreak

public void setMayNotBreak(boolean mayNotBreak)
Setter for the mayNotBreak variable.


isMayNotBreak

public boolean isMayNotBreak()
Getter for the mayNotbreak variable.


writeBorderAndBackground

public void writeBorderAndBackground(float xPos,
                                     float yPos,
                                     float currentMaxHeight,
                                     PdfPCell cell,
                                     PdfContentByte[] canvases)
Writes the border and background of one cell in the row.

Parameters:
xPos - The x-coordinate where the table starts on the canvas
yPos - The y-coordinate where the table starts on the canvas
currentMaxHeight - The height of the cell to be drawn.
cell -
canvases -
Since:
2.1.6 extra parameter currentMaxHeight

saveAndRotateCanvases

protected void saveAndRotateCanvases(PdfContentByte[] canvases,
                                     float a,
                                     float b,
                                     float c,
                                     float d,
                                     float e,
                                     float f)
Since:
2.1.6 private is now protected

restoreCanvases

protected void restoreCanvases(PdfContentByte[] canvases)
Since:
2.1.6 private is now protected

setColumn

public static float setColumn(ColumnText ct,
                              float left,
                              float bottom,
                              float right,
                              float top)
Since:
3.0.0 protected is now public static

writeCells

public void writeCells(int colStart,
                       int colEnd,
                       float xPos,
                       float yPos,
                       PdfContentByte[] canvases,
                       boolean reusable)
Writes a number of cells (not necessarily all cells).

Parameters:
colStart - The first column to be written. Remember that the column index starts with 0.
colEnd - The last column to be written. Remember that the column index starts with 0. If -1, all the columns to the end are written.
xPos - The x-coordinate where the table starts on the canvas
yPos - The y-coordinate where the table starts on the canvas
reusable - if set to false, the content in the cells is "consumed"; if true, you can reuse the cells, the row, the parent table as many times you want.
Since:
5.1.0 added the reusable parameter

isCalculated

public boolean isCalculated()
Checks if the dimensions of the columns were calculated.

Returns:
true if the dimensions of the columns were calculated

getMaxHeights

public float getMaxHeights()
Gets the maximum height of the row (i.e. of the 'highest' cell).

Returns:
the maximum height of the row

setMaxHeights

public void setMaxHeights(float maxHeight)
Changes the maximum height of the row (to make it higher). (added by Jin-Hsia Yang)

Parameters:
maxHeight - the new maximum height

copyRowContent

public void copyRowContent(PdfPTable table,
                           int idx)
Copies the content of a specific row in a table to this row. Don't do this if the rows have a different number of cells.

Parameters:
table - the table from which you want to copy a row
idx - the index of the row that needs to be copied
Since:
5.1.0

splitRow

public PdfPRow splitRow(PdfPTable table,
                        int rowIndex,
                        float new_height)
Splits a row to newHeight. The returned row is the remainder. It will return null if the newHeight was so small that only an empty row would result.

Parameters:
new_height - the new height
Returns:
the remainder row or null if the newHeight was so small that only an empty row would result

getCells

public PdfPCell[] getCells()
Returns the array of cells in the row. Please be extremely careful with this method. Use the cells as read only objects.

Returns:
an array of cells
Since:
2.1.1

hasRowspan

public boolean hasRowspan()
Checks if a cell in the row has a rowspan greater than 1.

Since:
5.1.0

getAccessibleAttribute

public PdfObject getAccessibleAttribute(PdfName key)
Description copied from interface: IAccessibleElement
Get the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).

Specified by:
getAccessibleAttribute in interface IAccessibleElement
Returns:

setAccessibleAttribute

public void setAccessibleAttribute(PdfName key,
                                   PdfObject value)
Description copied from interface: IAccessibleElement
Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).

Specified by:
setAccessibleAttribute in interface IAccessibleElement

getAccessibleAttributes

public HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface: IAccessibleElement
Gets all the properties of accessible element.

Specified by:
getAccessibleAttributes in interface IAccessibleElement
Returns:

getRole

public PdfName getRole()
Description copied from interface: IAccessibleElement
Gets the role of the accessible element.

Specified by:
getRole in interface IAccessibleElement
Returns:

setRole

public void setRole(PdfName role)
Description copied from interface: IAccessibleElement
Sets the role of the accessiblee element. Set role to null if you don't want to tag this element. Note that all child elements won't also be tagged.

Specified by:
setRole in interface IAccessibleElement

getId

public UUID getId()
Specified by:
getId in interface IAccessibleElement

setId

public void setId(UUID id)
Specified by:
setId in interface IAccessibleElement


Copyright © 2013. All Rights Reserved.