Gnostice PDFOne
Pro. Ed. v5.0.0


com.gnostice.pdfone
Class PdfTable

java.lang.Object
  extended bycom.gnostice.pdfone.PdfTable

public final class PdfTable
extends Object

This represents a table that can be rendered on a page. After a PdfTable object is created, cells can be added to it. After all cells are added, the PdfTable object can be added to a specified location on a page.

// Create a PDF page
PdfPage page = new PdfPage();

// Create a table
PdfTable tb = 
    new PdfTable(
          3, 
          new double[] { 1, 2, 2},
          0.4, 
          PdfMeasurement.MU_INCHES);
// Specify cell padding
tb.setCellBottomMargin(0.1);
tb.setCellTopMargin(0.1);
tb.setCellLeftMargin(0.1);
tb.setCellRightMargin(0.1);

// Add "Row 1" cells to the table
tb.addCell(1, 1, "S.No.", Color.blue);
tb.addCell(1, 1, "First Name", Color.RED);
tb.addCell(1, 1, "Second Name", Color.RED);

// Add "Row 2" cells to the table       
tb.addCell(1, 1, "1.");
tb.addCell(1, 1, "Abraham");
tb.addCell(1, 1, "Lincoln");

// Add "Row 3" cells to the table
tb.addCell(1, 1, "2.");
tb.addCell(1, 1, "Thomas");
tb.addCell(1, 1, "Jefferson");

// Add "Row 4" cells to the table       
tb.addCell(2, 1, "3.");
tb.addCell(1, 2, "George");
tb.addCell(1, 2, "Washington");

// Add the table to the page
page.addTable(tb, 100, 100);


Constructor Summary
PdfTable(int columns)
          Creates a table with specified number of columns.
PdfTable(int columns, double[] colwidth, double cellHeight, int measurementUnit)
          Constructs a new table with specified number of columns, column width, column height, and default measurement unit.
PdfTable(int columns, double[] colwidth, int measurementUnit)
          Constructs a new table with specified number of columns, column width, and default measurement unit.
 
Method Summary
 void addCell(int rowSpan, int colSpan)
          Adds a new cell that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, Color backgroundColor)
          Add a new cell (with specified background color) that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, PdfFormField formfield)
          Adds a new cell (with specified form field as the contents) that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, PdfImage image)
          Adds a new cell (with specified image as the contents) that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, String text)
          Adds specified cell (with specified text as contents) that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, String text, Color backgroundColor)
          Adds a new cell (with specified background color and contents) that spans specified number of rows and specified number of columns to the table.
 void addCell(int rowSpan, int colSpan, String text, Color backgroundColor, PdfFont font, int alignment)
          Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, text font, and text alignment to the table.
 void addCell(int rowSpan, int colSpan, String text, int alignment)
          Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents and text alignment.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font)
          Adds specified (that specified number of rows and columns) with specified text and text font.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font, Color backgroundColor)
          Adds specified (that specified number of rows and columns) with specified text, font for rendering the text, and background color to the table.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font, int alignment)
          Adds specified (that specified number of rows and columns) with specified text, font for rendering the text, and text alignment.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font, PdfImage image, Color backgroundColor, int alignment)
          Adds specified (that specified number of rows and columns) with specified text content, font for rendering the text, image content, background color, and content alignment.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font, PdfImage image, Color backgroundColor, int alignment, boolean fitImageinCell)
          Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, font for rendering the text, image that should be rendered inside the cell, background color, and image scaling to the table.
 void addCell(int rowSpan, int colSpan, String text, PdfFont font, String imagePath)
          Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, font for rendering the text, and pathaname of the image that should be rendered inside the cell.
 void addCell(int rowSpan, int colSpan, String text, PdfImage image, Color backgroundColor, int alignment)
          Adds specified (that specified number of rows and columns) with specified text content, font for rendering the text, image content, background color, and alignment to the table.
 void addCell(int rowSpan, int colSpan, String text, String imagePath)
          Adds specified (that specified number of rows and columns) with specified text and image contents to the table.
 void addCell(PdfCell c)
          Adds specified cell to the table.
 int getAlignment()
          Returns default alignment of contents of the cells in the table.
 boolean getAutoAdjRowHeight()
          Returns whether row height of the tables will be adjusted to accommodate the entire height of the contents of the cells.
 Color getBackgroundColor()
          Returns default background color of the cells in the table.
 double getCellBottomMargin()
          Returns default bottom padding of the contents in the cells in the table.
 double getCellLeftMargin()
          Returns default left padding of the contents of the cells in the table.
 double getCellRightMargin()
          Returns default right padding of the contents of the cells in the table.
 double getCellTopMargin()
          Returns default top padding of the contents of the cells in the table.
 double[] getColumnWidths()
          Returns widths of all columns in the table.
 PdfFont getFont()
          Returns defualt font used by the table.
 PdfPen getPen()
          Returns default pen used to stroke the table.
 double getRowHeight()
          Returns default height of the cells in the table.
 void setAlignment(int alignment)
          Specifies how contents of cells in the table are aligned.
 void setAutoAdjRowHeight(boolean autoAdjColumnHeight)
          Specifies whether row height of the tables need to be adjusted to accommodate the entire height of the contents of the cells.
 void setBackgroundColor(Color backgroundColor)
          Speifies default background color of the cells in the table.
 void setCellBottomMargin(double cellBottomMargin)
          Specifies default bottom padding of the contents of the cells in the table.
 void setCellLeftMargin(double cellLeftMargin)
          Specifies default left padding of the contents of the cells in the table.
 void setCellRightMargin(double cellRightMargin)
          Specifies default right padding of the contents of the cells in the table.
 void setCellTopMargin(double cellTopMargin)
          Specifies default top padding of the contents of the cells in the table.
 void setColumnWidth(double[] colwidth)
          Specifies widths of the columns in the table.
 void setFont(PdfFont font)
          Specifies default font for text contents in the table.
 void setPen(PdfPen pen)
          Specifies default pen with which contents of the table are stroked.
 void setRowHeight(double rowHeight)
          Specifies heights of the rows in the table.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfTable

public PdfTable(int columns)
Creates a table with specified number of columns.

Parameters:
columns - number of columns

PdfTable

public PdfTable(int columns,
                double[] colwidth,
                int measurementUnit)
         throws PdfException
Constructs a new table with specified number of columns, column width, and default measurement unit.

Parameters:
columns - number of columns
colwidth - width of the columns
measurementUnit - constant specified measurement unit with which lengths of various properties of the table are specified
Throws:
PdfException - if an illegal argument is supplied.

PdfTable

public PdfTable(int columns,
                double[] colwidth,
                double cellHeight,
                int measurementUnit)
         throws PdfException
Constructs a new table with specified number of columns, column width, column height, and default measurement unit.

Parameters:
columns - number of columns
colwidth - width of the columns
cellHeight - height of the columns
measurementUnit - constant specified measurement unit with which lengths of various properties of the table are specified
Throws:
PdfException - if an illegal argument is supplied.
Method Detail

addCell

public void addCell(int rowSpan,
                    int colSpan)
Adds a new cell that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text)
Adds specified cell (with specified text as contents) that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font)
Adds specified (that specified number of rows and columns) with specified text and text font.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font,
                    int alignment)
Adds specified (that specified number of rows and columns) with specified text, font for rendering the text, and text alignment.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell
alignment - constant specifying alignment of the text inside the cell
See Also:
PdfTextFormatter

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    Color backgroundColor,
                    PdfFont font,
                    int alignment)
Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, text font, and text alignment to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
backgroundColor - background color of the cell
font - font with which the text should be rendered inside the cell
alignment - constant specifying alignment of the text inside the cell
See Also:
PdfTextFormatter

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    int alignment)
Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents and text alignment.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
alignment - constant specifying alignment of the text inside the cell
See Also:
PdfTextFormatter

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    Color backgroundColor)
Adds a new cell (with specified background color and contents) that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
backgroundColor - background color of the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font,
                    Color backgroundColor)
Adds specified (that specified number of rows and columns) with specified text, font for rendering the text, and background color to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell
backgroundColor - background color of the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    PdfImage image)
Adds a new cell (with specified image as the contents) that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
image - image that should be rendered inside the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    Color backgroundColor)
Add a new cell (with specified background color) that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
backgroundColor - background color of the cell

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    String imagePath)
             throws IOException,
                    PdfException
Adds specified (that specified number of rows and columns) with specified text and image contents to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
imagePath - pathname of the image
Throws:
IOException - if an I/O error occurs.
PdfException - if an illegal argument is supplied.

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font,
                    String imagePath)
             throws IOException,
                    PdfException
Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, font for rendering the text, and pathaname of the image that should be rendered inside the cell.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell
imagePath - pathname of the image
Throws:
IOException - if an I/O error occurs.
PdfException - if an illegal argument is supplied.

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfImage image,
                    Color backgroundColor,
                    int alignment)
             throws IOException,
                    PdfException
Adds specified (that specified number of rows and columns) with specified text content, font for rendering the text, image content, background color, and alignment to the table. The text will be rendered over the image.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
image - image that should be rendered inside the cell
backgroundColor - background color of the cell
alignment - constant specifying alignment of the text inside the cell
Throws:
IOException - if an I/O error occurs.
PdfException - if an illegal argument is supplied.

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font,
                    PdfImage image,
                    Color backgroundColor,
                    int alignment)
Adds specified (that specified number of rows and columns) with specified text content, font for rendering the text, image content, background color, and content alignment.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell
image - image that should be rendered inside the cell
backgroundColor - background color of the cell
alignment - constant specifying alignment of the text inside the cell
See Also:
PdfTextFormatter

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    String text,
                    PdfFont font,
                    PdfImage image,
                    Color backgroundColor,
                    int alignment,
                    boolean fitImageinCell)
Adds a new cell (that spans specified number of rows and specified number of columns) with specified text contents, font for rendering the text, image that should be rendered inside the cell, background color, and image scaling to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
text - text that should be rendered inside the cell
font - font with which the text should be rendered inside the cell
image - image that should be rendered inside the cell
backgroundColor - background color of the cell
alignment - constant specifying alignment of the text inside the cell
fitImageinCell - whether the image needs to scaled up or down to fit the cell
See Also:
PdfTextFormatter

addCell

public void addCell(int rowSpan,
                    int colSpan,
                    PdfFormField formfield)
Adds a new cell (with specified form field as the contents) that spans specified number of rows and specified number of columns to the table.

Parameters:
rowSpan - number of rows that the new cell should span
colSpan - number of columns that the new cell should span
formfield - form field that should be rendered inside the cell

addCell

public void addCell(PdfCell c)
Adds specified cell to the table.

Parameters:
c - cell that needs to be added

getPen

public PdfPen getPen()
Returns default pen used to stroke the table.

Returns:
default pen
See Also:
setPen(PdfPen)

setPen

public void setPen(PdfPen pen)
Specifies default pen with which contents of the table are stroked.

Parameters:
pen - default pen
See Also:
getPen()

getAutoAdjRowHeight

public boolean getAutoAdjRowHeight()
Returns whether row height of the tables will be adjusted to accommodate the entire height of the contents of the cells.

Returns:
whether row height of the tables should be adjusted
See Also:
setAutoAdjRowHeight(boolean)

setAutoAdjRowHeight

public void setAutoAdjRowHeight(boolean autoAdjColumnHeight)
Specifies whether row height of the tables need to be adjusted to accommodate the entire height of the contents of the cells.

Parameters:
autoAdjColumnHeight - whether row height of the tables need to be adjusted
See Also:
getAutoAdjRowHeight()

getCellLeftMargin

public double getCellLeftMargin()
Returns default left padding of the contents of the cells in the table.

Returns:
default left padding
See Also:
setCellLeftMargin(double)

setCellLeftMargin

public void setCellLeftMargin(double cellLeftMargin)
Specifies default left padding of the contents of the cells in the table.

Parameters:
cellLeftMargin - default left padding
See Also:
getCellLeftMargin()

getCellTopMargin

public double getCellTopMargin()
Returns default top padding of the contents of the cells in the table.

Returns:
default top padding
See Also:
getCellTopMargin()

setCellTopMargin

public void setCellTopMargin(double cellTopMargin)
Specifies default top padding of the contents of the cells in the table.

Parameters:
cellTopMargin - default top padding
See Also:
getCellTopMargin()

getCellRightMargin

public double getCellRightMargin()
Returns default right padding of the contents of the cells in the table.

Returns:
default right padding
See Also:
setCellRightMargin(double)

setCellRightMargin

public void setCellRightMargin(double cellRightMargin)
Specifies default right padding of the contents of the cells in the table.

Parameters:
cellRightMargin - default right padding
See Also:
getCellRightMargin()

getCellBottomMargin

public double getCellBottomMargin()
Returns default bottom padding of the contents in the cells in the table.

Returns:
default bottom padding
See Also:
setCellBottomMargin(double)

setCellBottomMargin

public void setCellBottomMargin(double cellBottomMargin)
Specifies default bottom padding of the contents of the cells in the table.

Parameters:
cellBottomMargin - default bottom padding
See Also:
getCellBottomMargin()

getRowHeight

public double getRowHeight()
Returns default height of the cells in the table.

Returns:
default height of the cells
See Also:
setRowHeight(double)

setRowHeight

public void setRowHeight(double rowHeight)
Specifies heights of the rows in the table.

Parameters:
rowHeight - an array containing the heights
See Also:
getRowHeight()

getColumnWidths

public double[] getColumnWidths()
Returns widths of all columns in the table.

Returns:
an array containing all widths
See Also:
setColumnWidth(double[])

setColumnWidth

public void setColumnWidth(double[] colwidth)
Specifies widths of the columns in the table.

Parameters:
colwidth - an array containing the widths
See Also:
getColumnWidths()

getBackgroundColor

public Color getBackgroundColor()
Returns default background color of the cells in the table.

Returns:
default background color
See Also:
setBackgroundColor(Color)

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)
Speifies default background color of the cells in the table.

Parameters:
backgroundColor - default background color
See Also:
getBackgroundColor()

getFont

public PdfFont getFont()
Returns defualt font used by the table.

Returns:
defualt font
See Also:
setFont(PdfFont)

setFont

public void setFont(PdfFont font)
Specifies default font for text contents in the table.

Parameters:
font - default font
See Also:
getFont()

getAlignment

public int getAlignment()
Returns default alignment of contents of the cells in the table.

Returns:
constant specifying the alignment
See Also:
PdfTextFormatter

setAlignment

public void setAlignment(int alignment)
Specifies how contents of cells in the table are aligned.

Parameters:
alignment -
See Also:
getAlignment()

Gnostice PDFOne
Pro. Ed. v5.0.0

To contact our support team, send an e-mail to support@gnostice.com.
 
© 2010 Gnostice Information Technologies Private Limited. All rights reserved.
www.gnostice.com