Class PdfPCell
java.lang.Object
com.itextpdf.text.Rectangle
com.itextpdf.text.pdf.PdfPCell
- All Implemented Interfaces:
Element, IAccessibleElement
- Direct Known Subclasses:
HtmlCell, PdfPHeaderCell
A cell in a PdfPTable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate floatThis field is used to cache the height which is calculated on getMaxHeight() method call; this helps to avoid unnecessary recalculations on table drawing.private floatFixed height of the cell.private PdfPCellEventHolds value of property cellEvent.private intHolds value of property colspan.private ColumnTextprivate floatFixed height of the cell.protected ArrayList<PdfPHeaderCell> protected AccessibleElementIdprivate ImageHolds value of property image.private floatMinimum height of the cell.private booleanHolds value of property noWrap.private floatBottom padding of the cell.private floatLeft padding of the cell.private floatRight padding of the cell.private floatTop padding of the cell.protected PhraseThe text in the cell.protected PdfNameprivate intThe rotation of the cell.private intHolds value of property rowspan.private PdfPTableHolds value of property table.private booleanIncreases padding to include border if trueprivate booleanHolds value of property useDescender.private intVertical alignment of the cell.Fields inherited from class Rectangle
backgroundColor, border, borderColor, borderColorBottom, borderColorLeft, borderColorRight, borderColorTop, borderWidth, borderWidthBottom, borderWidthLeft, borderWidthRight, borderWidthTop, BOTTOM, BOX, LEFT, llx, lly, NO_BORDER, RIGHT, TOP, UNDEFINED, urx, ury, useVariableBordersFields inherited from interface Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, BODY, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CHAPTER, CHUNK, CREATIONDATE, CREATOR, DIV, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LANGUAGE, LIST, LISTITEM, MARKED, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK -
Constructor Summary
ConstructorsConstructorDescriptionPdfPCell()Constructs an emptyPdfPCell.Constructs aPdfPCellwith anImage.Constructs aPdfPCellwith anImage.Constructs a deep copy of aPdfPCell.Constructs aPdfPCellwith aPdfPtable.Constructs aPdfPCellwith aPdfPtable.Constructs aPdfPCellwith aPhrase. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElement(Element element) Adds an iText element to the cell.voidaddHeader(PdfPHeaderCell header) Get the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).Gets all the properties of accessible element.intGets the arabic shaping options.floatGets the height which was calculated on last call of getMaxHeight().floatGet the calculated height of the cell.Gets the cell event for this cell.intGetter for property colspan.Gets the ColumnText with the content of the cell.Returns the list of composite elements of the column.floatGets the effective bottom padding.floatGets the effective left padding.floatGets the effective right padding.floatGets the effective top padding.floatGets the extra space between paragraphs.floatGet the fixed height of the cell.floatGets the following paragraph lines indent.intGets the horizontal alignment for the cell.getId()getImage()Getter for property image.floatGets the first paragraph line indent.floatGets the fixed leading.floatReturns the height of the cell.floatGet the minimum height of the cell.floatGets the variable leading.floatGetter for property paddingBottom.floatfloatGetter for property paddingRight.floatGetter for property paddingTop.Gets thePhrasefrom this cell.floatGets the right paragraph lines indent.getRole()Gets the role of the accessible element.intGets the rotation of the cell.intGetter for property rowspan.intGets the run direction of the text content in the cellfloatGets the space/character extra spacing ratio for fully justified text.getTable()Getter for property table.intGets the vertical alignment for the cell.booleanbooleanTells you whether the height was calculated.booleanTells you whether the cell has a fixed height.booleanTells you whether the cell has a minimum height.booleanisInline()booleanisNoWrap()Getter for property noWrap.booleanGets state of first line height based on max ascenderbooleanIf true, then effective padding will include border widthsbooleanGetter for property useDescender.voidsetAccessibleAttribute(PdfName key, PdfObject value) Set the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).voidsetArabicOptions(int arabicOptions) Sets the arabic shaping options.voidsetCalculatedHeight(float calculatedHeight) Set a calculated height for the cell.voidsetCellEvent(PdfPCellEvent cellEvent) Sets the cell event for this cell.voidsetColspan(int colspan) Setter for property colspan.voidsetColumn(ColumnText column) Sets the columntext in the cell.voidsetExtraParagraphSpace(float extraParagraphSpace) Sets the extra space between paragraphs.voidsetFixedHeight(float fixedHeight) Set a fixed height for the cell.voidsetFollowingIndent(float indent) Sets the following paragraph lines indent.voidsetHorizontalAlignment(int horizontalAlignment) Sets the horizontal alignment for the cell.voidvoidSetter for property image.voidsetIndent(float indent) Sets the first paragraph line indent.voidsetLeading(float fixedLeading, float multipliedLeading) Sets the leading fixed and variable.voidsetMinimumHeight(float minimumHeight) Set a minimum height for the cell.voidsetNoWrap(boolean noWrap) Setter for property noWrap.voidsetPadding(float padding) Sets the padding of the contents in the cell (space between content and border).voidsetPaddingBottom(float paddingBottom) Setter for property paddingBottom.voidsetPaddingLeft(float paddingLeft) Setter for property paddingLeft.voidsetPaddingRight(float paddingRight) Setter for property paddingRight.voidsetPaddingTop(float paddingTop) Setter for property paddingTop.voidSets thePhrasefor this cell.voidsetRightIndent(float indent) Sets the right paragraph lines indent.voidSets the role of the accessiblee element.voidsetRotation(int rotation) Sets the rotation of the cell.voidsetRowspan(int rowspan) Setter for property rowspan.voidsetRunDirection(int runDirection) Sets the run direction of the text content in the cell.voidsetSpaceCharRatio(float spaceCharRatio) Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified.(package private) voidvoidsetUseAscender(boolean useAscender) Enables/ Disables adjustment of first line height based on max ascender.voidsetUseBorderPadding(boolean use) Adjusts effective padding to include border widths.voidsetUseDescender(boolean useDescender) Setter for property useDescender.voidsetVerticalAlignment(int verticalAlignment) Sets the vertical alignment for the cell.Methods inherited from class Rectangle
cloneNonPositionParameters, disableBorderSide, enableBorderSide, equals, getBackgroundColor, getBorder, getBorderColor, getBorderColorBottom, getBorderColorLeft, getBorderColorRight, getBorderColorTop, getBorderWidth, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getBottom, getBottom, getChunks, getGrayFill, getHeight, getLeft, getLeft, getRight, getRight, getTop, getTop, getWidth, hasBorder, hasBorders, isContent, isNestable, isUseVariableBorders, normalize, process, rectangle, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setBottom, setGrayFill, setLeft, setRight, setTop, setUseVariableBorders, softCloneNonPositionParameters, toString, type
-
Field Details
-
column
-
verticalAlignment
private int verticalAlignmentVertical alignment of the cell. -
paddingLeft
private float paddingLeftLeft padding of the cell. -
paddingRight
private float paddingRightRight padding of the cell. -
paddingTop
private float paddingTopTop padding of the cell. -
paddingBottom
private float paddingBottomBottom padding of the cell. -
fixedHeight
private float fixedHeightFixed height of the cell. -
calculatedHeight
private float calculatedHeightFixed height of the cell. -
minimumHeight
private float minimumHeightMinimum height of the cell. -
cachedMaxHeight
private float cachedMaxHeightThis field is used to cache the height which is calculated on getMaxHeight() method call; this helps to avoid unnecessary recalculations on table drawing. -
noWrap
private boolean noWrapHolds value of property noWrap. -
table
Holds value of property table. -
colspan
private int colspanHolds value of property colspan. -
rowspan
private int rowspanHolds value of property rowspan.- Since:
- 2.1.6
-
image
Holds value of property image. -
cellEvent
Holds value of property cellEvent. -
useDescender
private boolean useDescenderHolds value of property useDescender. -
useBorderPadding
private boolean useBorderPaddingIncreases padding to include border if true -
phrase
The text in the cell. -
rotation
private int rotationThe rotation of the cell. Possible values are 0, 90, 180 and 270. -
role
-
accessibleAttributes
-
id
-
headers
-
-
Constructor Details
-
PdfPCell
public PdfPCell()Constructs an emptyPdfPCell. The default padding is 2. -
PdfPCell
Constructs aPdfPCellwith aPhrase. The default padding is 2.- Parameters:
phrase- the text
-
PdfPCell
Constructs aPdfPCellwith anImage. The default padding is 0.- Parameters:
image- theImage
-
PdfPCell
Constructs aPdfPCellwith anImage. The default padding is 0.25 for a border width of 0.5.- Parameters:
image- theImagefit-trueto fit the image to the cell
-
PdfPCell
Constructs aPdfPCellwith aPdfPtable. This constructor allows nested tables. The default padding is 0.- Parameters:
table- ThePdfPTable
-
PdfPCell
-
PdfPCell
Constructs a deep copy of aPdfPCell.- Parameters:
cell- thePdfPCellto duplicate
-
-
Method Details
-
addElement
-
getPhrase
-
setPhrase
-
getHorizontalAlignment
public int getHorizontalAlignment()Gets the horizontal alignment for the cell.- Returns:
- the horizontal alignment for the cell
-
setHorizontalAlignment
public void setHorizontalAlignment(int horizontalAlignment) Sets the horizontal alignment for the cell. It could beElement.ALIGN_CENTERfor example.- Parameters:
horizontalAlignment- The horizontal alignment
-
getVerticalAlignment
public int getVerticalAlignment()Gets the vertical alignment for the cell.- Returns:
- the vertical alignment for the cell
-
setVerticalAlignment
public void setVerticalAlignment(int verticalAlignment) Sets the vertical alignment for the cell. It could beElement.ALIGN_MIDDLEfor example.- Parameters:
verticalAlignment- The vertical alignment
-
getEffectivePaddingLeft
public float getEffectivePaddingLeft()Gets the effective left padding. This will include the left border width ifisUseBorderPadding()is true.- Returns:
- effective value of property paddingLeft.
-
getPaddingLeft
public float getPaddingLeft()- Returns:
- Value of property paddingLeft.
-
setPaddingLeft
public void setPaddingLeft(float paddingLeft) Setter for property paddingLeft.- Parameters:
paddingLeft- New value of property paddingLeft.
-
getEffectivePaddingRight
public float getEffectivePaddingRight()Gets the effective right padding. This will include the right border width ifisUseBorderPadding()is true.- Returns:
- effective value of property paddingRight.
-
getPaddingRight
public float getPaddingRight()Getter for property paddingRight.- Returns:
- Value of property paddingRight.
-
setPaddingRight
public void setPaddingRight(float paddingRight) Setter for property paddingRight.- Parameters:
paddingRight- New value of property paddingRight.
-
getEffectivePaddingTop
public float getEffectivePaddingTop()Gets the effective top padding. This will include the top border width ifisUseBorderPadding()is true.- Returns:
- effective value of property paddingTop.
-
getPaddingTop
public float getPaddingTop()Getter for property paddingTop.- Returns:
- Value of property paddingTop.
-
setPaddingTop
public void setPaddingTop(float paddingTop) Setter for property paddingTop.- Parameters:
paddingTop- New value of property paddingTop.
-
getEffectivePaddingBottom
public float getEffectivePaddingBottom()Gets the effective bottom padding. This will include the bottom border width ifisUseBorderPadding()is true.- Returns:
- effective value of property paddingBottom.
-
getPaddingBottom
public float getPaddingBottom()Getter for property paddingBottom.- Returns:
- Value of property paddingBottom.
-
setPaddingBottom
public void setPaddingBottom(float paddingBottom) Setter for property paddingBottom.- Parameters:
paddingBottom- New value of property paddingBottom.
-
setPadding
public void setPadding(float padding) Sets the padding of the contents in the cell (space between content and border).- Parameters:
padding-
-
isUseBorderPadding
public boolean isUseBorderPadding()If true, then effective padding will include border widths- Returns:
- true if effective padding includes border widths
-
setUseBorderPadding
public void setUseBorderPadding(boolean use) Adjusts effective padding to include border widths.- Parameters:
use- adjust effective padding if true
-
setLeading
public void setLeading(float fixedLeading, float 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.- Parameters:
fixedLeading- the fixed leadingmultipliedLeading- the variable leading
-
getLeading
public float getLeading()Gets the fixed leading.- Returns:
- the leading
-
getMultipliedLeading
public float getMultipliedLeading()Gets the variable leading.- Returns:
- the leading
-
setIndent
public void setIndent(float indent) Sets the first paragraph line indent.- Parameters:
indent- the indent
-
getIndent
public float getIndent()Gets the first paragraph line indent.- Returns:
- the indent
-
getExtraParagraphSpace
public float getExtraParagraphSpace()Gets the extra space between paragraphs.- Returns:
- the extra space between paragraphs
-
setExtraParagraphSpace
public void setExtraParagraphSpace(float extraParagraphSpace) Sets the extra space between paragraphs.- Parameters:
extraParagraphSpace- the extra space between paragraphs
-
setCalculatedHeight
public void setCalculatedHeight(float calculatedHeight) Set a calculated height for the cell.- Parameters:
calculatedHeight- New value of property calculatedHeight.
-
getCalculatedHeight
public float getCalculatedHeight()Get the calculated height of the cell.- Returns:
- Value of property calculatedHeight.
-
hasCalculatedHeight
public boolean hasCalculatedHeight()Tells you whether the height was calculated.- Returns:
- true if the height was calculated.
-
setFixedHeight
public void setFixedHeight(float fixedHeight) Set a fixed height for the cell. This will automatically unset minimumHeight, if set.- Parameters:
fixedHeight- New value of property fixedHeight.
-
getFixedHeight
public float getFixedHeight()Get the fixed height of the cell.- Returns:
- Value of property fixedHeight.
-
hasFixedHeight
public boolean hasFixedHeight()Tells you whether the cell has a fixed height.- Returns:
- true is a fixed height was set.
- Since:
- 2.1.5
-
getCachedMaxHeight
public float getCachedMaxHeight()Gets the height which was calculated on last call of getMaxHeight(). If cell's bBox and content wasn't changed this value is actual maxHeight of the cell.- Returns:
- max height which was calculated on last call of getMaxHeight(); if getMaxHeight() wasn't called the return value is 0
-
hasCachedMaxHeight
public boolean hasCachedMaxHeight() -
setMinimumHeight
public void setMinimumHeight(float minimumHeight) Set a minimum height for the cell. This will automatically unset fixedHeight, if set.- Parameters:
minimumHeight- New value of property minimumHeight.
-
getMinimumHeight
public float getMinimumHeight()Get the minimum height of the cell.- Returns:
- Value of property minimumHeight.
-
hasMinimumHeight
public boolean hasMinimumHeight()Tells you whether the cell has a minimum height.- Returns:
- true if a minimum height was set.
- Since:
- 2.1.5
-
isNoWrap
public boolean isNoWrap()Getter for property noWrap.- Returns:
- Value of property noWrap.
-
setNoWrap
public void setNoWrap(boolean noWrap) Setter for property noWrap.- Parameters:
noWrap- New value of property noWrap.
-
getTable
-
setTable
-
getColspan
public int getColspan()Getter for property colspan.- Returns:
- Value of property colspan.
-
setColspan
public void setColspan(int colspan) Setter for property colspan.- Parameters:
colspan- New value of property colspan.
-
getRowspan
public int getRowspan()Getter for property rowspan.- Returns:
- Value of property rowspan.
- Since:
- 2.1.6
-
setRowspan
public void setRowspan(int rowspan) Setter for property rowspan.- Parameters:
rowspan- New value of property rowspan.- Since:
- 2.1.6
-
setFollowingIndent
public void setFollowingIndent(float indent) Sets the following paragraph lines indent.- Parameters:
indent- the indent
-
getFollowingIndent
public float getFollowingIndent()Gets the following paragraph lines indent.- Returns:
- the indent
-
setRightIndent
public void setRightIndent(float indent) Sets the right paragraph lines indent.- Parameters:
indent- the indent
-
getRightIndent
public float getRightIndent()Gets the right paragraph lines indent.- Returns:
- the indent
-
getSpaceCharRatio
public float getSpaceCharRatio()Gets the space/character extra spacing ratio for fully justified text.- Returns:
- the space/character extra spacing ratio
-
setSpaceCharRatio
public void setSpaceCharRatio(float spaceCharRatio) Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified. Extra word spacing will growspaceCharRatiotimes more than extra character spacing. If the ratio isPdfWriter.NO_SPACE_CHAR_RATIOthen the extra character spacing will be zero.- Parameters:
spaceCharRatio- the ratio between the extra word spacing and the extra character spacing
-
setRunDirection
public void setRunDirection(int 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.- Parameters:
runDirection-
-
getRunDirection
public int getRunDirection()Gets the run direction of the text content in the cell- Returns:
- One of the following values: PdfWriter.RUN_DIRECTION_DEFAULT, PdfWriter.RUN_DIRECTION_NO_BIDI, PdfWriter.RUN_DIRECTION_LTR or PdfWriter.RUN_DIRECTION_RTL.
-
getImage
-
setImage
Setter for property image.- Parameters:
image- New value of property image.
-
getCellEvent
-
setCellEvent
Sets the cell event for this cell.- Parameters:
cellEvent- the cell event
-
getArabicOptions
public int getArabicOptions()Gets the arabic shaping options.- Returns:
- the arabic shaping options
-
setArabicOptions
public void setArabicOptions(int arabicOptions) Sets the arabic shaping options. The option can be AR_NOVOWEL, AR_COMPOSEDTASHKEEL and AR_LIG.- Parameters:
arabicOptions- the arabic shaping options
-
isUseAscender
public boolean isUseAscender()Gets state of first line height based on max ascender- Returns:
- true if an ascender is to be used.
-
setUseAscender
public void setUseAscender(boolean useAscender) Enables/ Disables adjustment of first line height based on max ascender.- Parameters:
useAscender- adjust height if true
-
isUseDescender
public boolean isUseDescender()Getter for property useDescender.- Returns:
- Value of property useDescender.
-
setUseDescender
public void setUseDescender(boolean useDescender) Setter for property useDescender.- Parameters:
useDescender- New value of property useDescender.
-
getColumn
Gets the ColumnText with the content of the cell.- Returns:
- a columntext object
-
getCompositeElements
-
setColumn
-
getRotation
public int getRotation()Gets the rotation of the cell.- Overrides:
getRotationin classRectangle- Returns:
- the rotation of the cell.
-
setRotation
public void setRotation(int rotation) Sets the rotation of the cell. Possible values are 0, 90, 180 and 270.- Overrides:
setRotationin classRectangle- Parameters:
rotation- the rotation of the cell
-
getMaxHeight
public float getMaxHeight()Returns the height of the cell.- Returns:
- the height of the cell
- Since:
- 3.0.0
-
getAccessibleAttribute
Description copied from interface:IAccessibleElementGet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
getAccessibleAttributein interfaceIAccessibleElement- Parameters:
key-- Returns:
-
setAccessibleAttribute
Description copied from interface:IAccessibleElementSet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
setAccessibleAttributein interfaceIAccessibleElement- Parameters:
key-value-
-
getAccessibleAttributes
Description copied from interface:IAccessibleElementGets all the properties of accessible element.- Specified by:
getAccessibleAttributesin interfaceIAccessibleElement- Returns:
-
getRole
Description copied from interface:IAccessibleElementGets the role of the accessible element.- Specified by:
getRolein interfaceIAccessibleElement- Returns:
-
setRole
Description copied from interface:IAccessibleElementSets the role of the accessiblee element. Set role tonullif you don't want to tag this element. Note that all child elements won't also be tagged.- Specified by:
setRolein interfaceIAccessibleElement- Parameters:
role-
-
getId
- Specified by:
getIdin interfaceIAccessibleElement
-
setId
- Specified by:
setIdin interfaceIAccessibleElement
-
isInline
public boolean isInline()- Specified by:
isInlinein interfaceIAccessibleElement
-
addHeader
-
getHeaders
-