| Constructor: |
public PdfPCell() {
super(0, 0, 0, 0);
borderWidth = 0.5f;
border = BOX;
column.setLeading(0, 1);
}
Constructs an empty PdfPCell.
The default padding is 2. |
public PdfPCell(Phrase phrase) {
super(0, 0, 0, 0);
borderWidth = 0.5f;
border = BOX;
column.addText(this.phrase = phrase);
column.setLeading(0, 1);
}
Constructs a PdfPCell with a Phrase.
The default padding is 2. Parameters:
phrase - the text
|
public PdfPCell(Image image) {
this(image, false);
}
Constructs a PdfPCell with an Image.
The default padding is 0. Parameters:
image - the Image
|
public PdfPCell(PdfPTable table) {
this(table, null);
}
Constructs a PdfPCell with a PdfPtable.
This constructor allows nested tables.
The default padding is 0. Parameters:
table - The PdfPTable
|
public PdfPCell(PdfPCell cell) {
super(cell.llx, cell.lly, cell.urx, cell.ury);
cloneNonPositionParameters(cell);
verticalAlignment = cell.verticalAlignment;
paddingLeft = cell.paddingLeft;
paddingRight = cell.paddingRight;
paddingTop = cell.paddingTop;
paddingBottom = cell.paddingBottom;
phrase = cell.phrase;
fixedHeight = cell.fixedHeight;
minimumHeight = cell.minimumHeight;
noWrap = cell.noWrap;
colspan = cell.colspan;
rowspan = cell.rowspan;
if (cell.table != null)
table = new PdfPTable(cell.table);
image = Image.getInstance(cell.image);
cellEvent = cell.cellEvent;
useDescender = cell.useDescender;
column = ColumnText.duplicate(cell.column);
useBorderPadding = cell.useBorderPadding;
rotation = cell.rotation;
}
Constructs a deep copy of a PdfPCell. Parameters:
cell - the PdfPCell to duplicate
|
public PdfPCell(Image image,
boolean fit) {
super(0, 0, 0, 0);
borderWidth = 0.5f;
border = BOX;
if (fit) {
this.image = image;
column.setLeading(0, 1);
setPadding(borderWidth / 2);
}
else {
column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0)));
column.setLeading(0, 1);
setPadding(0);
}
}
Constructs a PdfPCell with an Image.
The default padding is 0.25 for a border width of 0.5. Parameters:
image - the Image
fit - true to fit the image to the cell
|
public PdfPCell(PdfPTable table,
PdfPCell style) {
super(0, 0, 0, 0);
borderWidth = 0.5f;
border = BOX;
column.setLeading(0, 1);
this.table = table;
table.setWidthPercentage(100);
table.setExtendLastRow(true);
column.addElement(table);
if (style != null) {
cloneNonPositionParameters(style);
verticalAlignment = style.verticalAlignment;
paddingLeft = style.paddingLeft;
paddingRight = style.paddingRight;
paddingTop = style.paddingTop;
paddingBottom = style.paddingBottom;
colspan = style.colspan;
rowspan = style.rowspan;
cellEvent = style.cellEvent;
useDescender = style.useDescender;
useBorderPadding = style.useBorderPadding;
rotation = style.rotation;
}
else
setPadding(0);
}
Constructs a PdfPCell with a PdfPtable.
This constructor allows nested tables. Parameters:
table - The PdfPTable
style - The style to apply to the cell (you could use getDefaultCell())
- since:
2.1.0 -
|
| Method from com.lowagie.text.pdf.PdfPCell Detail: |
public void addElement(Element element) {
if (table != null) {
table = null;
column.setText(null);
}
column.addElement(element);
}
Adds an iText element to the cell. |
void consumeHeight(float height) {
float rightLimit = getRight() - getEffectivePaddingRight();
float leftLimit = getLeft() + getEffectivePaddingLeft();
float bry = height - getEffectivePaddingTop() - getEffectivePaddingBottom();
if (getRotation() != 90 && getRotation() != 270) {
column.setSimpleColumn(leftLimit, bry + 0.001f, rightLimit, 0);
}
else {
column.setSimpleColumn(0, leftLimit, bry + 0.001f, rightLimit);
}
try {
column.go(true);
} catch (DocumentException e) {
// do nothing
}
}
Consumes part of the content of the cell. |
public int getArabicOptions() {
return column.getArabicOptions();
}
Gets the arabic shaping options. |
public PdfPCellEvent getCellEvent() {
return cellEvent;
}
Gets the cell event for this cell. |
public int getColspan() {
return colspan;
}
Getter for property colspan. |
public ColumnText getColumn() {
return column;
}
Gets the ColumnText with the content of the cell. |
public List getCompositeElements() {
return getColumn().compositeElements;
}
Returns the list of composite elements of the column. |
public float getEffectivePaddingBottom() {
if (isUseBorderPadding()) {
float border = getBorderWidthBottom()/(isUseVariableBorders()?1f:2f);
return paddingBottom + border;
}
return paddingBottom;
}
Gets the effective bottom padding.
This will include the bottom border width if
#isUseBorderPadding() is true. |
public float getEffectivePaddingLeft() {
if (isUseBorderPadding()) {
float border = getBorderWidthLeft() / (isUseVariableBorders() ? 1f : 2f);
return paddingLeft + border;
}
return paddingLeft;
}
Gets the effective left padding.
This will include the left border width if
#isUseBorderPadding() is true. |
public float getEffectivePaddingRight() {
if (isUseBorderPadding()) {
float border = getBorderWidthRight() / (isUseVariableBorders() ? 1f : 2f);
return paddingRight + border;
}
return paddingRight;
}
Gets the effective right padding. This will include
the right border width if #isUseBorderPadding() is true. |
public float getEffectivePaddingTop() {
if (isUseBorderPadding()) {
float border = getBorderWidthTop()/(isUseVariableBorders()?1f:2f);
return paddingTop + border;
}
return paddingTop;
}
|
public float getExtraParagraphSpace() {
return column.getExtraParagraphSpace();
}
Gets the extra space between paragraphs. |
public float getFixedHeight() {
return fixedHeight;
}
Get the fixed height of the cell. |
public float getFollowingIndent() {
return column.getFollowingIndent();
}
Gets the following paragraph lines indent. |
public int getHorizontalAlignment() {
return column.getAlignment();
}
Gets the horizontal alignment for the cell. |
public Image getImage() {
return image;
}
Getter for property image. |
public float getIndent() {
return column.getIndent();
}
Gets the first paragraph line indent. |
public float getLeading() {
return column.getLeading();
}
|
public float getMaxHeight() {
boolean pivoted = (getRotation() == 90 || getRotation() == 270);
Image img = getImage();
if (img != null) {
img.scalePercent(100);
float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth();
float scale = (getRight() - getEffectivePaddingRight()
- getEffectivePaddingLeft() - getLeft()) / refWidth;
img.scalePercent(scale * 100);
float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight();
setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight);
}
else {
if (pivoted && hasFixedHeight())
setBottom(getTop() - getFixedHeight());
else {
ColumnText ct = ColumnText.duplicate(getColumn());
float right, top, left, bottom;
if (pivoted) {
right = PdfPRow.RIGHT_LIMIT;
top = getRight() - getEffectivePaddingRight();
left = 0;
bottom = getLeft() + getEffectivePaddingLeft();
}
else {
right = isNoWrap() ? PdfPRow.RIGHT_LIMIT : getRight() - getEffectivePaddingRight();
top = getTop() - getEffectivePaddingTop();
left = getLeft() + getEffectivePaddingLeft();
bottom = hasFixedHeight() ? top + getEffectivePaddingBottom() - getFixedHeight() : PdfPRow.BOTTOM_LIMIT;
}
PdfPRow.setColumn(ct, left, bottom, right, top);
try {
ct.go(true);
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
if (pivoted)
setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - ct.getFilledWidth());
else {
float yLine = ct.getYLine();
if (isUseDescender())
yLine += ct.getDescender();
setBottom(yLine - getEffectivePaddingBottom());
}
}
}
float height = getHeight();
if (height < getFixedHeight())
height = getFixedHeight();
else if (height < getMinimumHeight())
height = getMinimumHeight();
return height;
}
Returns the height of the cell. |
public float getMinimumHeight() {
return minimumHeight;
}
Get the minimum height of the cell. |
public float getMultipliedLeading() {
return column.getMultipliedLeading();
}
Gets the variable leading. |
public float getPaddingBottom() {
return paddingBottom;
}
Getter for property paddingBottom. |
public float getPaddingLeft() {
return paddingLeft;
}
|
public float getPaddingRight() {
return paddingRight;
}
Getter for property paddingRight. |
public float getPaddingTop() {
return paddingTop;
}
Getter for property paddingTop. |
public Phrase getPhrase() {
return phrase;
}
Gets the Phrase from this cell. |
public float getRightIndent() {
return column.getRightIndent();
}
Gets the right paragraph lines indent. |
public int getRotation() {
return rotation;
}
Gets the rotation of the cell. |
public int getRowspan() {
return rowspan;
}
Getter for property rowspan. |
public int getRunDirection() {
return column.getRunDirection();
}
Gets the run direction of the text content in the cell |
public float getSpaceCharRatio() {
return column.getSpaceCharRatio();
}
Gets the space/character extra spacing ratio for fully justified text. |
public PdfPTable getTable() {
return table;
}
Getter for property table. |
public int getVerticalAlignment() {
return verticalAlignment;
}
Gets the vertical alignment for the cell. |
public boolean hasFixedHeight() {
return getFixedHeight() > 0;
}
Tells you whether the cell has a fixed height. |
public boolean hasMinimumHeight() {
return getMinimumHeight() > 0;
}
Tells you whether the cell has a minimum height. |
public boolean isNoWrap() {
return noWrap;
}
Getter for property noWrap. |
public boolean isUseAscender() {
return column.isUseAscender();
}
Gets state of first line height based on max ascender |
public boolean isUseBorderPadding() {
return useBorderPadding;
}
If true, then effective padding will include border widths |
public boolean isUseDescender() {
return useDescender;
}
Getter for property useDescender. |
public void setArabicOptions(int arabicOptions) {
column.setArabicOptions(arabicOptions);
}
Sets the arabic shaping options.
The option can be AR_NOVOWEL, AR_COMPOSEDTASHKEEL and AR_LIG. |
public void setCellEvent(PdfPCellEvent cellEvent) {
if (cellEvent == null)
this.cellEvent = null;
else if (this.cellEvent == null)
this.cellEvent = cellEvent;
else if (this.cellEvent instanceof PdfPCellEventForwarder)
((PdfPCellEventForwarder)this.cellEvent).addCellEvent(cellEvent);
else {
PdfPCellEventForwarder forward = new PdfPCellEventForwarder();
forward.addCellEvent(this.cellEvent);
forward.addCellEvent(cellEvent);
this.cellEvent = forward;
}
}
Sets the cell event for this cell. |
public void setColspan(int colspan) {
this.colspan = colspan;
}
Setter for property colspan. |
public void setColumn(ColumnText column) {
this.column = column;
}
Sets the columntext in the cell. |
public void setExtraParagraphSpace(float extraParagraphSpace) {
column.setExtraParagraphSpace(extraParagraphSpace);
}
Sets the extra space between paragraphs. |
public void setFixedHeight(float fixedHeight) {
this.fixedHeight = fixedHeight;
minimumHeight = 0;
}
Set a fixed height for the cell.
This will automatically unset minimumHeight, if set. |
public void setFollowingIndent(float indent) {
column.setFollowingIndent(indent);
}
Sets the following paragraph lines indent. |
public void setHorizontalAlignment(int horizontalAlignment) {
column.setAlignment(horizontalAlignment);
}
Sets the horizontal alignment for the cell. It could be
Element.ALIGN_CENTER for example. |
public void setImage(Image image) {
column.setText(null);
table = null;
this.image = image;
}
Setter for property image. |
public void setIndent(float indent) {
column.setIndent(indent);
}
Sets the first paragraph line indent. |
public void setLeading(float fixedLeading,
float multipliedLeading) {
column.setLeading(fixedLeading, multipliedLeading);
}
Sets the leading fixed and variable.
The resultant leading will be:
fixedLeading+multipliedLeading*maxFontSize
where maxFontSize is the size of the biggest font in the line. |
public void setMinimumHeight(float minimumHeight) {
this.minimumHeight = minimumHeight;
fixedHeight = 0;
}
Set a minimum height for the cell.
This will automatically unset fixedHeight, if set. |
public void setNoWrap(boolean noWrap) {
this.noWrap = noWrap;
}
Setter for property noWrap. |
public void setPadding(float padding) {
paddingBottom = padding;
paddingTop = padding;
paddingLeft = padding;
paddingRight = padding;
}
Sets the padding of the contents in the cell (space between content and border). |
public void setPaddingBottom(float paddingBottom) {
this.paddingBottom = paddingBottom;
}
Setter for property paddingBottom. |
public void setPaddingLeft(float paddingLeft) {
this.paddingLeft = paddingLeft;
}
Setter for property paddingLeft. |
public void setPaddingRight(float paddingRight) {
this.paddingRight = paddingRight;
}
Setter for property paddingRight. |
public void setPaddingTop(float paddingTop) {
this.paddingTop = paddingTop;
}
Setter for property paddingTop. |
public void setPhrase(Phrase phrase) {
table = null;
image = null;
column.setText(this.phrase = phrase);
}
Sets the Phrase for this cell. |
public void setRightIndent(float indent) {
column.setRightIndent(indent);
}
Sets the right paragraph lines indent. |
public void setRotation(int rotation) {
rotation %= 360;
if (rotation < 0)
rotation += 360;
if ((rotation % 90) != 0)
throw new IllegalArgumentException("Rotation must be a multiple of 90.");
this.rotation = rotation;
}
Sets the rotation of the cell.
Possible values are 0, 90, 180 and 270. |
public void setRowspan(int rowspan) {
this.rowspan = rowspan;
}
Setter for property rowspan. |
public void setRunDirection(int runDirection) {
column.setRunDirection(runDirection);
}
Sets the run direction of the text content in the cell.
May be either of:
PdfWriter.RUN_DIRECTION_DEFAULT, PdfWriter.RUN_DIRECTION_NO_BIDI,
PdfWriter.RUN_DIRECTION_LTR or PdfWriter.RUN_DIRECTION_RTL. |
public void setSpaceCharRatio(float spaceCharRatio) {
column.setSpaceCharRatio(spaceCharRatio);
}
Sets the ratio between the extra word spacing and the
extra character spacing when the text is fully justified.
Extra word spacing will grow spaceCharRatio times more
than extra character spacing.
If the ratio is PdfWriter.NO_SPACE_CHAR_RATIO then the
extra character spacing will be zero. |
void setTable(PdfPTable table) {
this.table = table;
column.setText(null);
image = null;
if (table != null) {
table.setExtendLastRow(verticalAlignment == Element.ALIGN_TOP);
column.addElement(table);
table.setWidthPercentage(100);
}
}
|
public void setUseAscender(boolean useAscender) {
column.setUseAscender(useAscender);
}
Enables/ Disables adjustment of first line height based on max ascender. |
public void setUseBorderPadding(boolean use) {
useBorderPadding = use;
}
Adjusts effective padding to include border widths. |
public void setUseDescender(boolean useDescender) {
this.useDescender = useDescender;
}
Setter for property useDescender. |
public void setVerticalAlignment(int verticalAlignment) {
if (table != null)
table.setExtendLastRow(verticalAlignment == Element.ALIGN_TOP);
this.verticalAlignment = verticalAlignment;
}
Sets the vertical alignment for the cell. It could be
Element.ALIGN_MIDDLE for example. |