Class Chunk

java.lang.Object
com.lowagie.text.Chunk
All Implemented Interfaces:
Element

@Deprecated public class Chunk extends Object implements Element
Deprecated.
This is the smallest significant part of text that can be added to a document.

Most elements can be divided in one or more Chunks. A chunk is a String with a certain Font. All other layout parameters should be defined in the object to which this chunk of text is added.

Example:


 Chunk chunk = new Chunk("Hello world",
 FontFactory.getFont(FontFactory.COURIER, 20, Font.ITALIC, new Color(255, 0, 0)));  document.add(chunk);

 
  • Field Details

  • Constructor Details

    • Chunk

      public Chunk()
      Deprecated.
      Empty constructor.
    • Chunk

      public Chunk(Chunk ck)
      Deprecated.
      A Chunk copy constructor.
      Parameters:
      ck - the Chunk to be copied
    • Chunk

      public Chunk(String content, Font font)
      Deprecated.
      Constructs a chunk of text with a certain content and a certain Font.
      Parameters:
      content - the content
      font - the font
    • Chunk

      public Chunk(String content)
      Deprecated.
      Constructs a chunk of text with a certain content, without specifying a Font.
      Parameters:
      content - the content
    • Chunk

      public Chunk(char c, Font font)
      Deprecated.
      Constructs a chunk of text with a char and a certain Font.
      Parameters:
      c - the content
      font - the font
    • Chunk

      public Chunk(char c)
      Deprecated.
      Constructs a chunk of text with a char, without specifying a Font .
      Parameters:
      c - the content
    • Chunk

      public Chunk(Image image, float offsetX, float offsetY)
      Deprecated.
      Constructs a chunk containing an Image.
      Parameters:
      image - the image
      offsetX - the image offset in the x direction
      offsetY - the image offset in the y direction
    • Chunk

      public Chunk(DrawInterface separator)
      Deprecated.
      Creates a separator Chunk. Note that separator chunks can't be used in combination with tab chunks!
      Parameters:
      separator - the drawInterface to use to draw the separator.
      Since:
      2.1.2
    • Chunk

      public Chunk(DrawInterface separator, boolean vertical)
      Deprecated.
      Creates a separator Chunk. Note that separator chunks can't be used in combination with tab chunks!
      Parameters:
      separator - the drawInterface to use to draw the separator.
      vertical - true if this is a vertical separator
      Since:
      2.1.2
    • Chunk

      public Chunk(DrawInterface separator, float tabPosition)
      Deprecated.
      Creates a tab Chunk. Note that separator chunks can't be used in combination with tab chunks!
      Parameters:
      separator - the drawInterface to use to draw the tab.
      tabPosition - an X coordinate that will be used as start position for the next Chunk.
      Since:
      2.1.2
    • Chunk

      public Chunk(DrawInterface separator, float tabPosition, boolean newline)
      Deprecated.
      Creates a tab Chunk. Note that separator chunks can't be used in combination with tab chunks!
      Parameters:
      separator - the drawInterface to use to draw the tab.
      tabPosition - an X coordinate that will be used as start position for the next Chunk.
      newline - if true, a newline will be added if the tabPosition has already been reached.
      Since:
      2.1.2
    • Chunk

      public Chunk(Image image, float offsetX, float offsetY, boolean changeLeading)
      Deprecated.
      Constructs a chunk containing an Image.
      Parameters:
      image - the image
      offsetX - the image offset in the x direction
      offsetY - the image offset in the y direction
      changeLeading - true if the leading has to be adapted to the image
  • Method Details

    • process

      public boolean process(ElementListener listener)
      Deprecated.
      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
    • type

      public int type()
      Deprecated.
      Gets the type of the text element.
      Specified by:
      type in interface Element
      Returns:
      a type
    • getChunks

      public ArrayList<Element> getChunks()
      Deprecated.
      Gets all the chunks in this element.
      Specified by:
      getChunks in interface Element
      Returns:
      an ArrayList
    • append

      public StringBuffer append(String string)
      Deprecated.
      appends some text to this Chunk.
      Parameters:
      string - String
      Returns:
      a StringBuffer
    • getFont

      public Font getFont()
      Deprecated.
      Gets the font of this Chunk.
      Returns:
      a Font
    • setFont

      public void setFont(Font font)
      Deprecated.
      Sets the font of this Chunk.
      Parameters:
      font - a Font
    • getContent

      public String getContent()
      Deprecated.
      Returns the content of this Chunk.
      Returns:
      a String
    • toString

      public String toString()
      Deprecated.
      Returns the content of this Chunk.
      Specified by:
      toString in interface Element
      Overrides:
      toString in class Object
      Returns:
      a String
    • isEmpty

      public boolean isEmpty()
      Deprecated.
      Checks is this Chunk is empty.
      Returns:
      false if the Chunk contains other characters than space.
    • getWidthPoint

      public float getWidthPoint()
      Deprecated.
      Gets the width of the Chunk in points.
      Returns:
      a width in points
    • hasAttributes

      public boolean hasAttributes()
      Deprecated.
      Checks the attributes of this Chunk.
      Returns:
      false if there aren't any.
    • getChunkAttributes

      public Map<String,Object> getChunkAttributes()
      Deprecated.
      Gets the attributes for this Chunk.

      It may be null.

      Returns:
      the attributes for this Chunk
    • setChunkAttributes

      public void setChunkAttributes(Map<String,Object> attributes)
      Deprecated.
      Sets the attributes all at once.
      Parameters:
      attributes - the attributes of a Chunk
    • getHorizontalScaling

      public float getHorizontalScaling()
      Deprecated.
      Gets the horizontal scaling.
      Returns:
      a percentage in float
    • setHorizontalScaling

      public Chunk setHorizontalScaling(float scale)
      Deprecated.
      Sets the text horizontal scaling. A value of 1 is normal and a value of 0.5f shrinks the text to half it's width.
      Parameters:
      scale - the horizontal scaling factor
      Returns:
      this Chunk
    • setUnderline

      public Chunk setUnderline(float thickness, float yPosition)
      Deprecated.
      Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always the Chunk width. Multiple call to this method will produce multiple lines.
      Parameters:
      thickness - the absolute thickness of the line
      yPosition - the absolute y position relative to the baseline
      Returns:
      this Chunk
    • setUnderline

      public Chunk setUnderline(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int cap)
      Deprecated.
      Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always the Chunk width. Multiple call to this method will produce multiple lines.
      Parameters:
      color - the color of the line or null to follow the text color
      thickness - the absolute thickness of the line
      thicknessMul - the thickness multiplication factor with the font size
      yPosition - the absolute y position relative to the baseline
      yPositionMul - the position multiplication factor with the font size
      cap - the end line cap. Allowed values are PdfContentByte.LINE_CAP_BUTT, PdfContentByte.LINE_CAP_ROUND and PdfContentByte.LINE_CAP_PROJECTING_SQUARE
      Returns:
      this Chunk
    • getTextRise

      public float getTextRise()
      Deprecated.
      Gets the text displacement relative to the baseline.
      Returns:
      a displacement in points
    • setTextRise

      public Chunk setTextRise(float rise)
      Deprecated.
      Sets the text displacement relative to the baseline. Positive values rise the text, negative values lower the text.

      It can be used to implement sub/superscript.

      Parameters:
      rise - the displacement in points
      Returns:
      this Chunk
    • setSkew

      public Chunk setSkew(float alpha, float beta)
      Deprecated.
      Skews the text to simulate italic and other effects. Try alpha=0 and beta=12.
      Parameters:
      alpha - the first angle in degrees
      beta - the second angle in degrees
      Returns:
      this Chunk
    • setBackground

      public Chunk setBackground(Color color)
      Deprecated.
      Sets the color of the background Chunk.
      Parameters:
      color - the color of the background
      Returns:
      this Chunk
    • setBackground

      public Chunk setBackground(Color color, float extraLeft, float extraBottom, float extraRight, float extraTop)
      Deprecated.
      Sets the color and the size of the background Chunk.
      Parameters:
      color - the color of the background
      extraLeft - increase the size of the rectangle in the left
      extraBottom - increase the size of the rectangle in the bottom
      extraRight - increase the size of the rectangle in the right
      extraTop - increase the size of the rectangle in the top
      Returns:
      this Chunk
    • setTextRenderMode

      public Chunk setTextRenderMode(int mode, float strokeWidth, Color strokeColor)
      Deprecated.
      Sets the text rendering mode. It can outline text, simulate bold and make text invisible.
      Parameters:
      mode - the text rendering mode. It can be PdfContentByte.TEXT_RENDER_MODE_FILL, PdfContentByte.TEXT_RENDER_MODE_STROKE, PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE and PdfContentByte.TEXT_RENDER_MODE_INVISIBLE.
      strokeWidth - the stroke line width for the modes PdfContentByte.TEXT_RENDER_MODE_STROKE and PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE.
      strokeColor - the stroke color or null to follow the text color
      Returns:
      this Chunk
    • setSplitCharacter

      public Chunk setSplitCharacter(SplitCharacter splitCharacter)
      Deprecated.
      Sets the split characters.
      Parameters:
      splitCharacter - the SplitCharacter interface
      Returns:
      this Chunk
    • setRemoteGoto

      public Chunk setRemoteGoto(String filename, String name)
      Deprecated.
      Sets a goto for a remote destination for this Chunk.
      Parameters:
      filename - the file name of the destination document
      name - the name of the destination to go to
      Returns:
      this Chunk
    • setRemoteGoto

      public Chunk setRemoteGoto(String filename, int page)
      Deprecated.
      Sets a goto for a remote destination for this Chunk.
      Parameters:
      filename - the file name of the destination document
      page - the page of the destination to go to. First page is 1
      Returns:
      this Chunk
    • setLocalGoto

      public Chunk setLocalGoto(String name)
      Deprecated.
      Sets a local goto for this Chunk.

      There must be a local destination matching the name.

      Parameters:
      name - the name of the destination to go to
      Returns:
      this Chunk
    • setLocalDestination

      public Chunk setLocalDestination(String name)
      Deprecated.
      Sets a local destination for this Chunk.
      Parameters:
      name - the name for this destination
      Returns:
      this Chunk
    • setGenericTag

      public Chunk setGenericTag(String text)
      Deprecated.
      Sets the generic tag Chunk.

      The text for this tag can be retrieved with PdfPageEvent.

      Parameters:
      text - the text for the tag
      Returns:
      this Chunk
    • getImage

      public Image getImage()
      Deprecated.
      Returns the image.
      Returns:
      the image
    • setAction

      public Chunk setAction(PdfAction action)
      Deprecated.
      Sets an action for this Chunk.
      Parameters:
      action - the action
      Returns:
      this Chunk
    • setAnchor

      public Chunk setAnchor(URL url)
      Deprecated.
      Sets an anchor for this Chunk.
      Parameters:
      url - the URL to link to
      Returns:
      this Chunk
    • setAnchor

      public Chunk setAnchor(String url)
      Deprecated.
      Sets an anchor for this Chunk.
      Parameters:
      url - the url to link to
      Returns:
      this Chunk
    • setNewPage

      public Chunk setNewPage()
      Deprecated.
      Sets a new page tag..
      Returns:
      this Chunk
    • setAnnotation

      public Chunk setAnnotation(PdfAnnotation annotation)
      Deprecated.
      Sets a generic annotation to this Chunk.
      Parameters:
      annotation - the annotation
      Returns:
      this Chunk
    • isContent

      public boolean isContent()
      Deprecated.
      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()
      Deprecated.
      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:
    • getHyphenation

      public HyphenationEvent getHyphenation()
      Deprecated.
      Returns the hyphenation (if present).
      Returns:
      an object of HyphenationEvent
      Since:
      2.1.2
    • setHyphenation

      public Chunk setHyphenation(HyphenationEvent hyphenation)
      Deprecated.
      sets the hyphenation engine to this Chunk.
      Parameters:
      hyphenation - the hyphenation engine
      Returns:
      this Chunk
    • getCharacterSpacing

      public float getCharacterSpacing()
      Deprecated.
      Gets the character spacing.
      Returns:
      a value in float
    • setCharacterSpacing

      public Chunk setCharacterSpacing(float charSpace)
      Deprecated.
      Sets the character spacing.
      Parameters:
      charSpace - the character spacing value
      Returns:
      this Chunk