Gnostice PDFOne
Pro. Ed. v5.0.0


com.gnostice.pdfone
Class PdfCell

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

public final class PdfCell
extends Object

This class represents a cell in a table. Using the method PdfTable.addCell(PdfCell), cells can be added to a table.

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

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

// Create a PDF font
PdfFont fHelveticaBold = 
    PdfFont.create("Helvetica", 
                   PdfFont.BOLD, 
                   12, 
                   PdfEncodings.CP1252);
fHelveticaBold.setColor(Color.BLACK);

// Create cells
PdfCell cell11 = 
   new PdfCell(1,1,Color.LIGHT_GRAY, PdfTextFormatter.CENTER);
cell11.setFont(fHelveticaBold);
PdfCell cell12 = (PdfCell) cell11.clone();
PdfCell cell13 = (PdfCell) cell11.clone();

PdfCell cell21 = new PdfCell(1,1);
PdfCell cell22 = (PdfCell) cell21.clone();
PdfCell cell23 = (PdfCell) cell11.clone();
PdfCell cell31 = (PdfCell) cell21.clone();
PdfCell cell32 = (PdfCell) cell21.clone();
PdfCell cell33 = (PdfCell) cell21.clone();

// Specify text displayed in the cells
cell11.setText("S.No.");
cell12.setText("First Name");
cell13.setText("Second Name");
cell21.setText("1.");
cell22.setText("George");
cell23.setText("Washington");
cell31.setText("2.");
cell32.setText("Abraham");
cell33.setText("Lincoln");


// Add the cells to the table
tb.addCell(cell11);
tb.addCell(cell12);
tb.addCell(cell13);
tb.addCell(cell21);
tb.addCell(cell22);
tb.addCell(cell23);
tb.addCell(cell31);
tb.addCell(cell32);
tb.addCell(cell33);

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


Field Summary
 boolean fitImageinCell
          Whether images need to be stretched to fit inside the cell.
 
Constructor Summary
PdfCell(int rowSpan, int colSpan)
          Constructs a cell that spans specified rows and columns.
PdfCell(int rowSpan, int colSpan, Color backgroundColor, int alignment)
          Constructs a cell that spans specified number of rows and columns and with specified background color and content alignment.
 
Method Summary
 Object clone()
           
 void fitImageinCell(boolean fitImageinCell)
           
 int getAlignment()
          Returns constant specifying how contents of the cell are aligned.
 Color getBackgroundColor()
          Returns background color of the cell.
 double getCellBottomMargin()
          Returns bottom padding of the cell.
 double getCellLeftMargin()
          Returns left padding of the cell.
 double getCellRightMargin()
          Returns right padding of the cell.
 double getCellTopMargin()
          Returns top padding of the cell.
 int getColSpan()
          Returns number of cells the cell spans.
 PdfFont getFont()
          Returns default font with which text is rendered inside the cell.
 PdfFormField getFormField()
           
 double getHeight()
          Returns height of the cell.
 PdfImage getImage()
           
 int getRowSpan()
          Returns number of rows the cells spans.
 String getText()
          Returns text that is displayed inside the cell.
 double getWidth()
          Returns width of the cell.
 boolean isFitImageinCell()
           
 void setAlignment(int alignment)
          Specifies how contents of the cells are aligned.
 void setBackgroundColor(Color backgroundColor)
          Specifies background color of the cell.
 void setCellBottomMargin(double cellBottomMargin)
          Specifies bottom padding of the cell.
 void setCellLeftMargin(double cellLeftMargin)
          Specifies left padding of the cell.
 void setCellRightMargin(double cellRightMargin)
          Specifies right padding of the cell.
 void setCellTopMargin(double cellTopMargin)
          Specifies top padding of the cell.
 void setColSpan(int colSpan)
          Specifies number of columns the cell spans.
 void setFont(PdfFont font)
          Specifies default font with which text needs rendered inside the cell.
 void setFormField(PdfFormField formfield)
           
 void setHeight(double height)
          Specifies height of the cell.
 void setImage(PdfImage image)
           
 void setRowSpan(int rowSpan)
          Specifies number of rows the cell spans.
 void setText(String text)
          Specifies text that needs to be displayed inside the cell.
 void setWidth(double width)
          Specifies width of the cell.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fitImageinCell

public boolean fitImageinCell
Whether images need to be stretched to fit inside the cell.

Constructor Detail

PdfCell

public PdfCell(int rowSpan,
               int colSpan)
Constructs a cell that spans specified rows and columns.

Parameters:
rowSpan - number of rows that the cell needs to span
colSpan - number of columns that the cell needs to span

PdfCell

public PdfCell(int rowSpan,
               int colSpan,
               Color backgroundColor,
               int alignment)
Constructs a cell that spans specified number of rows and columns and with specified background color and content alignment.

Parameters:
rowSpan - number of rows that the cell needs to span
colSpan - number of columns that the cell needs to span
backgroundColor - background color of the cell
alignment - PdfTextFormatter.LEFT specifying alignment of the cell's contents
Method Detail

setWidth

public void setWidth(double width)
Specifies width of the cell.

Parameters:
width - width of the cell
See Also:
getWidth()

setHeight

public void setHeight(double height)
Specifies height of the cell.

Parameters:
height - height of the cell
See Also:
getHeight(), setWidth(double)

setRowSpan

public void setRowSpan(int rowSpan)
Specifies number of rows the cell spans.

Parameters:
rowSpan - number of rows the cell spans
See Also:
getRowSpan()

setColSpan

public void setColSpan(int colSpan)
Specifies number of columns the cell spans.

Parameters:
colSpan - number of columns the cell spans
See Also:
getColSpan()

setText

public void setText(String text)
Specifies text that needs to be displayed inside the cell.

Parameters:
text - text that needs to be displayed inside the cell
See Also:
getText()

setCellLeftMargin

public void setCellLeftMargin(double cellLeftMargin)
Specifies left padding of the cell.

Parameters:
cellLeftMargin - left padding of the cell
See Also:
getCellLeftMargin()

setCellRightMargin

public void setCellRightMargin(double cellRightMargin)
Specifies right padding of the cell.

Parameters:
cellRightMargin - right padding of the cell
See Also:
getCellRightMargin()

setCellBottomMargin

public void setCellBottomMargin(double cellBottomMargin)
Specifies bottom padding of the cell.

Parameters:
cellBottomMargin - bottom padding of the cell
See Also:
getCellBottomMargin()

setCellTopMargin

public void setCellTopMargin(double cellTopMargin)
Specifies top padding of the cell.

Parameters:
cellTopMargin - top padding of the cell
See Also:
getCellTopMargin()

getCellLeftMargin

public double getCellLeftMargin()
Returns left padding of the cell.

Returns:
left padding of the cell
See Also:
setCellLeftMargin(double)

getCellRightMargin

public double getCellRightMargin()
Returns right padding of the cell.

Returns:
right padding of the cell
See Also:
setCellRightMargin(double)

getCellTopMargin

public double getCellTopMargin()
Returns top padding of the cell.

Returns:
top padding of the cell
See Also:
setCellTopMargin(double)

getCellBottomMargin

public double getCellBottomMargin()
Returns bottom padding of the cell.

Returns:
bottom padding of the cell
See Also:
setCellBottomMargin(double)

getText

public String getText()
Returns text that is displayed inside the cell.

Returns:
text that is displayed inside the cell
See Also:
setText(String)

getColSpan

public int getColSpan()
Returns number of cells the cell spans.

Returns:
number of cells the cell spans
See Also:
setColSpan(int)

getHeight

public double getHeight()
Returns height of the cell.

Returns:
height of the cell.
See Also:
setHeight(double), getWidth()

getRowSpan

public int getRowSpan()
Returns number of rows the cells spans.

Returns:
number of rows the cells spans
See Also:
setRowSpan(int)

getWidth

public double getWidth()
Returns width of the cell.

Returns:
width of the cell
See Also:
setWidth(double)

getAlignment

public int getAlignment()
Returns constant specifying how contents of the cell are aligned.

Returns:
constant specifying how contents of the cell are aligned
See Also:
PdfTextFormatter, setAlignment(int)

setAlignment

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

Parameters:
alignment - constant specifying how contents of the cells are aligned
See Also:
getAlignment(), PdfTextFormatter

getBackgroundColor

public Color getBackgroundColor()
Returns background color of the cell.

Returns:
background color of the cell
See Also:
setBackgroundColor(Color)

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)
Specifies background color of the cell.

Parameters:
backgroundColor - background color of the cell
See Also:
getBackgroundColor()

setFont

public void setFont(PdfFont font)
Specifies default font with which text needs rendered inside the cell.

Parameters:
font - default font with which text needs rendered inside the cell
See Also:
getFont()

getFont

public PdfFont getFont()
Returns default font with which text is rendered inside the cell.

Returns:
default font with which text is rendered inside the cell
See Also:
setFont(PdfFont)

setFormField

public void setFormField(PdfFormField formfield)

getFormField

public PdfFormField getFormField()

setImage

public void setImage(PdfImage image)

getImage

public PdfImage getImage()

fitImageinCell

public void fitImageinCell(boolean fitImageinCell)

isFitImageinCell

public boolean isFitImageinCell()

clone

public Object clone()

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