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 class
PdfDiv.BorderTopStyle
static class
PdfDiv.DisplayType
static class
PdfDiv.FloatType
static class
PdfDiv.PositionType
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<PdfName,PdfObject>
accessibleAttributes
private BaseColor
backgroundColor
private Image
backgroundImage
private java.lang.Float
backgroundImageHeight
private java.lang.Float
backgroundImageWidth
private PdfDiv.BorderTopStyle
borderTopStyle
private java.lang.Float
bottom
private java.util.ArrayList<Element>
content
private float
contentHeight
private float
contentWidth
private PdfDiv.DisplayType
display
private FloatLayout
floatLayout
private PdfDiv.FloatType
floatType
private java.lang.Float
height
protected AccessibleElementId
id
private boolean
keepTogether
Defines if the div should be kept on one page if possibleprivate java.lang.Float
left
private float
paddingBottom
private float
paddingLeft
private float
paddingRight
private float
paddingTop
private java.lang.Float
percentageHeight
private java.lang.Float
percentageWidth
private PdfDiv.PositionType
position
private java.lang.Float
right
protected PdfName
role
protected int
runDirection
protected float
spacingAfter
The spacing after the table.protected float
spacingBefore
The spacing before the table.private int
textAlignment
private java.lang.Float
top
private java.lang.Float
width
private float
yLine
-
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 void
addElement(Element element)
PdfObject
getAccessibleAttribute(PdfName key)
Get the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).java.util.HashMap<PdfName,PdfObject>
getAccessibleAttributes()
Gets all the properties of accessible element.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.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.BaseColor
getBackgroundColor()
PdfDiv.BorderTopStyle
getBorderTopStyle()
java.lang.Float
getBottom()
java.util.List<Chunk>
getChunks()
Gets all the chunks in this element.java.util.ArrayList<Element>
getContent()
float
getContentHeight()
float
getContentWidth()
PdfDiv.DisplayType
getDisplay()
PdfDiv.FloatType
getFloatType()
java.lang.Float
getHeight()
AccessibleElementId
getId()
boolean
getKeepTogether()
java.lang.Float
getLeft()
float
getPaddingBottom()
float
getPaddingLeft()
float
getPaddingRight()
float
getPaddingTop()
java.lang.Float
getPercentageHeight()
java.lang.Float
getPercentageWidth()
PdfDiv.PositionType
getPosition()
java.lang.Float
getRight()
PdfName
getRole()
Gets the role of the accessible element.int
getRunDirection()
float
getSpacingAfter()
Gets the spacing after this table.float
getSpacingBefore()
Gets the spacing before this table.int
getTextAlignment()
Gets the alignment of this paragraph.java.lang.Float
getTop()
java.lang.Float
getWidth()
float
getYLine()
boolean
isContent()
Checks if this element is a content object.boolean
isInline()
boolean
isNestable()
Checks if this element is nestable.int
layout(PdfContentByte canvas, boolean useAscender, boolean simulate, float llx, float lly, float urx, float ury)
boolean
process(ElementListener listener)
Processes the element by adding it (or the different parts) to anElementListener
.void
setAccessibleAttribute(PdfName key, PdfObject value)
Set the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).void
setBackgroundColor(BaseColor backgroundColor)
void
setBackgroundImage(Image image)
Image will be scaled to fit in the div occupied area.void
setBackgroundImage(Image image, float width, float height)
Image will be scaled to fit in the div occupied area.void
setBorderTopStyle(PdfDiv.BorderTopStyle borderTopStyle)
void
setBottom(java.lang.Float bottom)
void
setContent(java.util.ArrayList<Element> content)
void
setContentHeight(float contentHeight)
void
setContentWidth(float contentWidth)
void
setDisplay(PdfDiv.DisplayType display)
void
setFloatType(PdfDiv.FloatType floatType)
void
setHeight(java.lang.Float height)
void
setId(AccessibleElementId id)
void
setKeepTogether(boolean keepTogether)
void
setLeft(java.lang.Float left)
void
setPaddingBottom(float paddingBottom)
void
setPaddingLeft(float paddingLeft)
void
setPaddingRight(float paddingRight)
void
setPaddingTop(float paddingTop)
void
setPercentageHeight(java.lang.Float percentageHeight)
void
setPercentageWidth(java.lang.Float percentageWidth)
void
setPosition(PdfDiv.PositionType position)
void
setRight(java.lang.Float right)
void
setRole(PdfName role)
Sets the role of the accessiblee element.void
setRunDirection(int runDirection)
void
setSpacingAfter(float spacing)
Sets the spacing after this table.void
setSpacingBefore(float spacing)
Sets the spacing before this table.void
setTextAlignment(int textAlignment)
Sets the alignment of this paragraph.void
setTop(java.lang.Float top)
void
setWidth(java.lang.Float width)
int
type()
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:Element
Checks if this element is a content object. If not, it's a metadata object.- Specified by:
isContent
in 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:Element
Checks if this element is nestable.- Specified by:
isNestable
in 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:
setSpacingBefore
in interfaceSpaceable
- Parameters:
spacing
- the new spacing
-
setSpacingAfter
public void setSpacingAfter(float spacing)
Sets the spacing after this table.- Specified by:
setSpacingAfter
in interfaceSpaceable
- Parameters:
spacing
- the new spacing
-
getSpacingBefore
public float getSpacingBefore()
Gets the spacing before this table.- Specified by:
getSpacingBefore
in interfaceSpaceable
- Returns:
- the spacing
-
getSpacingAfter
public float getSpacingAfter()
Gets the spacing after this table.- Specified by:
getSpacingAfter
in 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:
getPaddingTop
in interfaceSpaceable
-
setPaddingTop
public void setPaddingTop(float paddingTop)
- Specified by:
setPaddingTop
in 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:IAccessibleElement
Get the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).- Specified by:
getAccessibleAttribute
in interfaceIAccessibleElement
- Returns:
-
setAccessibleAttribute
public void setAccessibleAttribute(PdfName key, PdfObject value)
Description copied from interface:IAccessibleElement
Set the attribute of accessible element (everything inA
dictionary +Lang
,Alt
,ActualText
,E
).- Specified by:
setAccessibleAttribute
in interfaceIAccessibleElement
-
getAccessibleAttributes
public java.util.HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface:IAccessibleElement
Gets all the properties of accessible element.- Specified by:
getAccessibleAttributes
in interfaceIAccessibleElement
- Returns:
-
getRole
public PdfName getRole()
Description copied from interface:IAccessibleElement
Gets the role of the accessible element.- Specified by:
getRole
in interfaceIAccessibleElement
- Returns:
-
setRole
public void setRole(PdfName role)
Description copied from interface:IAccessibleElement
Sets the role of the accessiblee element. Set role tonull
if you don't want to tag this element. Note that all child elements won't also be tagged.- Specified by:
setRole
in interfaceIAccessibleElement
-
getId
public AccessibleElementId getId()
- Specified by:
getId
in interfaceIAccessibleElement
-
setId
public void setId(AccessibleElementId id)
- Specified by:
setId
in interfaceIAccessibleElement
-
isInline
public boolean isInline()
- Specified by:
isInline
in interfaceIAccessibleElement
-
-