Package com.itextpdf.text.pdf
Class PdfDiv
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfDiv
-
- All Implemented Interfaces:
Spaceable,Element,IAccessibleElement
public class PdfDiv extends java.lang.Object implements Element, Spaceable, IAccessibleElement
A special element to put a collection of elements at an absolute position.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPdfDiv.BorderTopStylestatic classPdfDiv.DisplayTypestatic classPdfDiv.FloatTypestatic classPdfDiv.PositionType
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<PdfName,PdfObject>accessibleAttributesprivate BaseColorbackgroundColorprivate ImagebackgroundImageprivate java.lang.FloatbackgroundImageHeightprivate java.lang.FloatbackgroundImageWidthprivate PdfDiv.BorderTopStyleborderTopStyleprivate java.lang.Floatbottomprivate java.util.ArrayList<Element>contentprivate floatcontentHeightprivate floatcontentWidthprivate PdfDiv.DisplayTypedisplayprivate FloatLayoutfloatLayoutprivate PdfDiv.FloatTypefloatTypeprivate java.lang.Floatheightprotected AccessibleElementIdidprivate booleankeepTogetherDefines if the div should be kept on one page if possibleprivate java.lang.Floatleftprivate floatpaddingBottomprivate floatpaddingLeftprivate floatpaddingRightprivate floatpaddingTopprivate java.lang.FloatpercentageHeightprivate java.lang.FloatpercentageWidthprivate PdfDiv.PositionTypepositionprivate java.lang.Floatrightprotected PdfNameroleprotected intrunDirectionprotected floatspacingAfterThe spacing after the table.protected floatspacingBeforeThe spacing before the table.private inttextAlignmentprivate java.lang.Floattopprivate java.lang.Floatwidthprivate floatyLine-
Fields inherited from interface com.itextpdf.text.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
Constructors Constructor Description PdfDiv()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElement(Element element)PdfObjectgetAccessibleAttribute(PdfName key)Get the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).java.util.HashMap<PdfName,PdfObject>getAccessibleAttributes()Gets all the properties of accessible element.floatgetActualHeight()IMPROTANT NOTE: be careful with this method because it would return correct result only in case iflayout(PdfContentByte, boolean, boolean, float, float, float, float)was already called.floatgetActualWidth()IMPROTANT NOTE: be careful with this method because it would return correct result only in case iflayout(PdfContentByte, boolean, boolean, float, float, float, float)was already called.BaseColorgetBackgroundColor()PdfDiv.BorderTopStylegetBorderTopStyle()java.lang.FloatgetBottom()java.util.List<Chunk>getChunks()Gets all the chunks in this element.java.util.ArrayList<Element>getContent()floatgetContentHeight()floatgetContentWidth()PdfDiv.DisplayTypegetDisplay()PdfDiv.FloatTypegetFloatType()java.lang.FloatgetHeight()AccessibleElementIdgetId()booleangetKeepTogether()java.lang.FloatgetLeft()floatgetPaddingBottom()floatgetPaddingLeft()floatgetPaddingRight()floatgetPaddingTop()java.lang.FloatgetPercentageHeight()java.lang.FloatgetPercentageWidth()PdfDiv.PositionTypegetPosition()java.lang.FloatgetRight()PdfNamegetRole()Gets the role of the accessible element.intgetRunDirection()floatgetSpacingAfter()Gets the spacing after this table.floatgetSpacingBefore()Gets the spacing before this table.intgetTextAlignment()Gets the alignment of this paragraph.java.lang.FloatgetTop()java.lang.FloatgetWidth()floatgetYLine()booleanisContent()Checks if this element is a content object.booleanisInline()booleanisNestable()Checks if this element is nestable.intlayout(PdfContentByte canvas, boolean useAscender, boolean simulate, float llx, float lly, float urx, float ury)booleanprocess(ElementListener listener)Processes the element by adding it (or the different parts) to anElementListener.voidsetAccessibleAttribute(PdfName key, PdfObject value)Set the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).voidsetBackgroundColor(BaseColor backgroundColor)voidsetBackgroundImage(Image image)Image will be scaled to fit in the div occupied area.voidsetBackgroundImage(Image image, float width, float height)Image will be scaled to fit in the div occupied area.voidsetBorderTopStyle(PdfDiv.BorderTopStyle borderTopStyle)voidsetBottom(java.lang.Float bottom)voidsetContent(java.util.ArrayList<Element> content)voidsetContentHeight(float contentHeight)voidsetContentWidth(float contentWidth)voidsetDisplay(PdfDiv.DisplayType display)voidsetFloatType(PdfDiv.FloatType floatType)voidsetHeight(java.lang.Float height)voidsetId(AccessibleElementId id)voidsetKeepTogether(boolean keepTogether)voidsetLeft(java.lang.Float left)voidsetPaddingBottom(float paddingBottom)voidsetPaddingLeft(float paddingLeft)voidsetPaddingRight(float paddingRight)voidsetPaddingTop(float paddingTop)voidsetPercentageHeight(java.lang.Float percentageHeight)voidsetPercentageWidth(java.lang.Float percentageWidth)voidsetPosition(PdfDiv.PositionType position)voidsetRight(java.lang.Float right)voidsetRole(PdfName role)Sets the role of the accessiblee element.voidsetRunDirection(int runDirection)voidsetSpacingAfter(float spacing)Sets the spacing after this table.voidsetSpacingBefore(float spacing)Sets the spacing before this table.voidsetTextAlignment(int textAlignment)Sets the alignment of this paragraph.voidsetTop(java.lang.Float top)voidsetWidth(java.lang.Float width)inttype()Gets the type of the text element.
-
-
-
Field Detail
-
content
private java.util.ArrayList<Element> content
-
left
private java.lang.Float left
-
top
private java.lang.Float top
-
right
private java.lang.Float right
-
bottom
private java.lang.Float bottom
-
width
private java.lang.Float width
-
height
private java.lang.Float height
-
percentageHeight
private java.lang.Float percentageHeight
-
percentageWidth
private java.lang.Float percentageWidth
-
contentWidth
private float contentWidth
-
contentHeight
private float contentHeight
-
textAlignment
private int textAlignment
-
paddingLeft
private float paddingLeft
-
paddingRight
private float paddingRight
-
paddingTop
private float paddingTop
-
paddingBottom
private float paddingBottom
-
floatType
private PdfDiv.FloatType floatType
-
position
private PdfDiv.PositionType position
-
display
private PdfDiv.DisplayType display
-
floatLayout
private FloatLayout floatLayout
-
borderTopStyle
private PdfDiv.BorderTopStyle borderTopStyle
-
yLine
private float yLine
-
runDirection
protected int runDirection
-
keepTogether
private boolean keepTogether
Defines if the div should be kept on one page if possible
-
role
protected PdfName role
-
id
protected AccessibleElementId id
-
backgroundColor
private BaseColor backgroundColor
-
backgroundImage
private Image backgroundImage
-
backgroundImageWidth
private java.lang.Float backgroundImageWidth
-
backgroundImageHeight
private java.lang.Float backgroundImageHeight
-
spacingBefore
protected float spacingBefore
The spacing before the table.
-
spacingAfter
protected float spacingAfter
The spacing after the table.
-
-
Method Detail
-
getContentWidth
public float getContentWidth()
-
setContentWidth
public void setContentWidth(float contentWidth)
-
getContentHeight
public float getContentHeight()
-
setContentHeight
public void setContentHeight(float contentHeight)
-
getActualHeight
public float getActualHeight()
IMPROTANT NOTE: be careful with this method because it would return correct result only in case iflayout(PdfContentByte, boolean, boolean, float, float, float, float)was already called.- Returns:
- the actual height the div would require to layout it's content
-
getActualWidth
public float getActualWidth()
IMPROTANT NOTE: be careful with this method because it would return correct result only in case iflayout(PdfContentByte, boolean, boolean, float, float, float, float)was already called.- Returns:
- the actual width the div would require to layout it's content
-
getPercentageHeight
public java.lang.Float getPercentageHeight()
-
setPercentageHeight
public void setPercentageHeight(java.lang.Float percentageHeight)
-
getPercentageWidth
public java.lang.Float getPercentageWidth()
-
setPercentageWidth
public void setPercentageWidth(java.lang.Float percentageWidth)
-
getDisplay
public PdfDiv.DisplayType getDisplay()
-
setDisplay
public void setDisplay(PdfDiv.DisplayType display)
-
getBackgroundColor
public BaseColor getBackgroundColor()
-
setBackgroundColor
public void setBackgroundColor(BaseColor backgroundColor)
-
setBackgroundImage
public void setBackgroundImage(Image image)
Image will be scaled to fit in the div occupied area.
-
setBackgroundImage
public void setBackgroundImage(Image image, float width, float height)
Image will be scaled to fit in the div occupied area.
-
getYLine
public float getYLine()
-
getRunDirection
public int getRunDirection()
-
setRunDirection
public void setRunDirection(int runDirection)
-
getKeepTogether
public boolean getKeepTogether()
-
setKeepTogether
public void setKeepTogether(boolean keepTogether)
-
getChunks
public java.util.List<Chunk> getChunks()
Gets all the chunks in this element.
-
type
public int type()
Gets the type of the text element.
-
isContent
public boolean isContent()
Description copied from interface:ElementChecks if this element is a content object. If not, it's a metadata object.- Specified by:
isContentin interfaceElement- Returns:
- true if this is a 'content' element; false if this is a 'metadata' element
- Since:
- iText 2.0.8
- See Also:
Element.isContent()
-
isNestable
public boolean isNestable()
Description copied from interface:ElementChecks if this element is nestable.- Specified by:
isNestablein interfaceElement- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
Element.isNestable()
-
process
public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to anElementListener.
-
setSpacingBefore
public void setSpacingBefore(float spacing)
Sets the spacing before this table.- Specified by:
setSpacingBeforein interfaceSpaceable- Parameters:
spacing- the new spacing
-
setSpacingAfter
public void setSpacingAfter(float spacing)
Sets the spacing after this table.- Specified by:
setSpacingAfterin interfaceSpaceable- Parameters:
spacing- the new spacing
-
getSpacingBefore
public float getSpacingBefore()
Gets the spacing before this table.- Specified by:
getSpacingBeforein interfaceSpaceable- Returns:
- the spacing
-
getSpacingAfter
public float getSpacingAfter()
Gets the spacing after this table.- Specified by:
getSpacingAfterin interfaceSpaceable- Returns:
- the spacing
-
getTextAlignment
public int getTextAlignment()
Gets the alignment of this paragraph.- Returns:
- textAlignment
-
setTextAlignment
public void setTextAlignment(int textAlignment)
Sets the alignment of this paragraph.- Parameters:
textAlignment- the new alignment
-
addElement
public void addElement(Element element)
-
getLeft
public java.lang.Float getLeft()
-
setLeft
public void setLeft(java.lang.Float left)
-
getRight
public java.lang.Float getRight()
-
setRight
public void setRight(java.lang.Float right)
-
getTop
public java.lang.Float getTop()
-
setTop
public void setTop(java.lang.Float top)
-
getBottom
public java.lang.Float getBottom()
-
setBottom
public void setBottom(java.lang.Float bottom)
-
getWidth
public java.lang.Float getWidth()
-
setWidth
public void setWidth(java.lang.Float width)
-
getHeight
public java.lang.Float getHeight()
-
setHeight
public void setHeight(java.lang.Float height)
-
getPaddingLeft
public float getPaddingLeft()
-
setPaddingLeft
public void setPaddingLeft(float paddingLeft)
-
getPaddingRight
public float getPaddingRight()
-
setPaddingRight
public void setPaddingRight(float paddingRight)
-
getPaddingTop
public float getPaddingTop()
- Specified by:
getPaddingTopin interfaceSpaceable
-
setPaddingTop
public void setPaddingTop(float paddingTop)
- Specified by:
setPaddingTopin interfaceSpaceable
-
getPaddingBottom
public float getPaddingBottom()
-
setPaddingBottom
public void setPaddingBottom(float paddingBottom)
-
getFloatType
public PdfDiv.FloatType getFloatType()
-
setFloatType
public void setFloatType(PdfDiv.FloatType floatType)
-
getPosition
public PdfDiv.PositionType getPosition()
-
setPosition
public void setPosition(PdfDiv.PositionType position)
-
getContent
public java.util.ArrayList<Element> getContent()
-
setContent
public void setContent(java.util.ArrayList<Element> content)
-
getBorderTopStyle
public PdfDiv.BorderTopStyle getBorderTopStyle()
-
setBorderTopStyle
public void setBorderTopStyle(PdfDiv.BorderTopStyle borderTopStyle)
-
layout
public int layout(PdfContentByte canvas, boolean useAscender, boolean simulate, float llx, float lly, float urx, float ury) throws DocumentException
- Throws:
DocumentException
-
getAccessibleAttribute
public PdfObject getAccessibleAttribute(PdfName key)
Description copied from interface:IAccessibleElementGet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
getAccessibleAttributein interfaceIAccessibleElement- Returns:
-
setAccessibleAttribute
public void setAccessibleAttribute(PdfName key, PdfObject value)
Description copied from interface:IAccessibleElementSet the attribute of accessible element (everything inAdictionary +Lang,Alt,ActualText,E).- Specified by:
setAccessibleAttributein interfaceIAccessibleElement
-
getAccessibleAttributes
public java.util.HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface:IAccessibleElementGets all the properties of accessible element.- Specified by:
getAccessibleAttributesin interfaceIAccessibleElement- Returns:
-
getRole
public PdfName getRole()
Description copied from interface:IAccessibleElementGets the role of the accessible element.- Specified by:
getRolein interfaceIAccessibleElement- Returns:
-
setRole
public void setRole(PdfName role)
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
-
getId
public AccessibleElementId getId()
- Specified by:
getIdin interfaceIAccessibleElement
-
setId
public void setId(AccessibleElementId id)
- Specified by:
setIdin interfaceIAccessibleElement
-
isInline
public boolean isInline()
- Specified by:
isInlinein interfaceIAccessibleElement
-
-