Class PdfDiv

java.lang.Object
com.itextpdf.text.pdf.PdfDiv
All Implemented Interfaces:
Spaceable, Element, IAccessibleElement

public class PdfDiv extends Object implements Element, Spaceable, IAccessibleElement
A special element to put a collection of elements at an absolute position.
  • Field Details

    • content

      private ArrayList<Element> content
    • left

      private Float left
    • top

      private Float top
    • bottom

      private Float bottom
    • width

      private Float width
    • height

      private Float height
    • percentageHeight

      private Float percentageHeight
    • percentageWidth

      private 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
    • accessibleAttributes

      protected HashMap<PdfName,PdfObject> accessibleAttributes
    • id

      protected AccessibleElementId id
    • backgroundColor

      private BaseColor backgroundColor
    • backgroundImage

      private Image backgroundImage
    • backgroundImageWidth

      private Float backgroundImageWidth
    • backgroundImageHeight

      private Float backgroundImageHeight
    • spacingBefore

      protected float spacingBefore
      The spacing before the table.
    • spacingAfter

      protected float spacingAfter
      The spacing after the table.
  • Constructor Details

    • PdfDiv

      public PdfDiv()
  • Method Details

    • 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 if layout(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 if layout(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 Float getPercentageHeight()
    • setPercentageHeight

      public void setPercentageHeight(Float percentageHeight)
    • getPercentageWidth

      public Float getPercentageWidth()
    • setPercentageWidth

      public void setPercentageWidth(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 List<Chunk> getChunks()
      Gets all the chunks in this element.
      Specified by:
      getChunks in interface Element
      Returns:
      an ArrayList
    • type

      public int type()
      Gets the type of the text element.
      Specified by:
      type in interface Element
      Returns:
      a type
    • 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 interface Element
      Returns:
      true if this is a 'content' element; false if this is a 'metadata' element
      Since:
      iText 2.0.8
      See Also:
    • isNestable

      public boolean isNestable()
      Description copied from interface: Element
      Checks if this element is nestable.
      Specified by:
      isNestable in interface Element
      Returns:
      true if this element can be nested inside other elements.
      Since:
      iText 2.0.8
      See Also:
    • process

      public boolean process(ElementListener listener)
      Processes the element by adding it (or the different parts) to an ElementListener.
      Specified by:
      process in interface Element
      Parameters:
      listener - an ElementListener
      Returns:
      true if the element was processed successfully
    • setSpacingBefore

      public void setSpacingBefore(float spacing)
      Sets the spacing before this table.
      Specified by:
      setSpacingBefore in interface Spaceable
      Parameters:
      spacing - the new spacing
    • setSpacingAfter

      public void setSpacingAfter(float spacing)
      Sets the spacing after this table.
      Specified by:
      setSpacingAfter in interface Spaceable
      Parameters:
      spacing - the new spacing
    • getSpacingBefore

      public float getSpacingBefore()
      Gets the spacing before this table.
      Specified by:
      getSpacingBefore in interface Spaceable
      Returns:
      the spacing
    • getSpacingAfter

      public float getSpacingAfter()
      Gets the spacing after this table.
      Specified by:
      getSpacingAfter in interface Spaceable
      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 Float getLeft()
    • setLeft

      public void setLeft(Float left)
    • getRight

      public Float getRight()
    • setRight

      public void setRight(Float right)
    • getTop

      public Float getTop()
    • setTop

      public void setTop(Float top)
    • getBottom

      public Float getBottom()
    • setBottom

      public void setBottom(Float bottom)
    • getWidth

      public Float getWidth()
    • setWidth

      public void setWidth(Float width)
    • getHeight

      public Float getHeight()
    • setHeight

      public void setHeight(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 interface Spaceable
    • setPaddingTop

      public void setPaddingTop(float paddingTop)
      Specified by:
      setPaddingTop in interface Spaceable
    • 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 ArrayList<Element> getContent()
    • setContent

      public void setContent(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 in A dictionary + Lang, Alt, ActualText, E).
      Specified by:
      getAccessibleAttribute in interface IAccessibleElement
      Parameters:
      key -
      Returns:
    • setAccessibleAttribute

      public void setAccessibleAttribute(PdfName key, PdfObject value)
      Description copied from interface: IAccessibleElement
      Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
      Specified by:
      setAccessibleAttribute in interface IAccessibleElement
      Parameters:
      key -
      value -
    • getAccessibleAttributes

      public HashMap<PdfName,PdfObject> getAccessibleAttributes()
      Description copied from interface: IAccessibleElement
      Gets all the properties of accessible element.
      Specified by:
      getAccessibleAttributes in interface IAccessibleElement
      Returns:
    • getRole

      public PdfName getRole()
      Description copied from interface: IAccessibleElement
      Gets the role of the accessible element.
      Specified by:
      getRole in interface IAccessibleElement
      Returns:
    • setRole

      public void setRole(PdfName role)
      Description copied from interface: IAccessibleElement
      Sets the role of the accessiblee element. Set role to null if you don't want to tag this element. Note that all child elements won't also be tagged.
      Specified by:
      setRole in interface IAccessibleElement
      Parameters:
      role -
    • getId

      public AccessibleElementId getId()
      Specified by:
      getId in interface IAccessibleElement
    • setId

      public void setId(AccessibleElementId id)
      Specified by:
      setId in interface IAccessibleElement
    • isInline

      public boolean isInline()
      Specified by:
      isInline in interface IAccessibleElement