Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.lowagie.text.pdf
Class PdfChunk

    java.lang.Object
      com.lowagie.text.pdf.PdfChunk

All Implemented Interfaces:
  SplitCharacter

    public class PdfChunk

extends Object
implements SplitCharacter

A `PdfChunk` is the PDF translation of a `Chunk`.

A `PdfChunk` is a `PdfString` in a certain `PdfFont` and `Color`.

See Also:
  `PdfString`, `Chunk`, `Font`

Field Summary
`protected HashMap` | `attributes` Metric attributes.
`protected BaseFont` | `baseFont`
`protected boolean` | `changeLeading` Indicates if the height and offset of the Image has to be taken into account
`protected String` | `encoding` The encoding.
`protected PdfFont` | `font` The font for this `PdfChunk`.
`protected Image` | `image` The image in this `PdfChunk`, if it has one
`private static float` | `ITALIC_ANGLE`
`private static HashMap` | `keysAttributes` The allowed attributes in variable `attributes`.
`private static HashMap` | `keysNoStroke` The allowed attributes in variable `noStroke`.
`protected boolean` | `newlineSplit` `true` if the chunk split was cause by a newline.
`protected HashMap` | `noStroke` Non metric attributes.
`protected float` | `offsetX` The offset in the x direction for the image
`protected float` | `offsetY` The offset in the y direction for the image
`private static char[]` | `singleSpace`
`protected SplitCharacter` | `splitCharacter`
`private static PdfChunk[]` | `thisChunk`
`protected String` | `value` The value of this object.

Constructor Summary
`PdfChunk(Chunk chunk, PdfAction action)` Constructs a `PdfChunk`-object.
`PdfChunk(String string, PdfChunk other)` Constructs a `PdfChunk`-object.

Method Summary
`boolean` | `changeLeading()`
`(package private) Color` | `color()` Returns the color of this `Chunk`.
`(package private) PdfFont` | `font()` Returns the font of this `Chunk`.
`(package private) Object` | `getAttribute(String name)` Gets an attribute.
`(package private) float` | `getCharWidth(char c)`
`(package private) String` | `getEncoding()` Gets the encoding of this string.
`(package private) Image` | `getImage()` Gets the image in the `PdfChunk`.
`(package private) float` | `getImageOffsetX()` Gets the image offset in the x direction
`(package private) float` | `getImageOffsetY()` Gets the image offset in the y direction
`float` | `getTextRise()` Gets the text displacement relatiev to the baseline.
`char` | `getUnicodeEquivalent(char c)` Gets the Unicode equivalent to a CID.
`float` | `getWidthCorrected(float charSpacing, float wordSpacing)` Gets the width of the `PdfChunk` taking into account the extra character and word spacing.
`protected int` | `getWord(String text, int start)`
`(package private) boolean` | `isAttribute(String name)` Checks if the attribute exists.
`(package private) boolean` | `isExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)`
`(package private) boolean` | `isImage()` Checks if there is an image in the `PdfChunk`.
`boolean` | `isNewlineSplit()` Checks if the `PdfChunk` split was caused by a newline.
`(package private) boolean` | `isSpecialEncoding()` Tells you if this string is in Chinese, Japanese, Korean or Identity-H.
`boolean` | `isSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)` Checks if a character can be used to split a `PdfString`.
`(package private) boolean` | `isStroked()` Checks if this `PdfChunk` needs some special metrics handling.
`(package private) int` | `length()`
`static boolean` | `noPrint(char c)`
`(package private) void` | `setImageOffsetX(float offsetX)` Sets the image offset in the x direction
`(package private) void` | `setImageOffsetY(float offsetY)` Sets the image offset in the y direction
`(package private) void` | `setValue(String value)` sets the value.
`(package private) PdfChunk` | `split(float width)` Splits this `PdfChunk` if it's too long for the given width.
`String` | `toString()`
`(package private) String` | `trim(String string)` Removes all the ' ' and '-'-characters on the right of a `String`.
`float` | `trimFirstSpace()`
`float` | `trimLastSpace()` Trims the last space.
`(package private) PdfChunk` | `truncate(float width)` Truncates this `PdfChunk` if it's too long for the given width.
`(package private) float` | `width()` Returns the width of this `PdfChunk`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### singleSpace

    private static final char[] singleSpace

### thisChunk

    private static final PdfChunk[] thisChunk

### ITALIC_ANGLE

    private static final float ITALIC_ANGLE

See Also:
  Constant Field Values

### keysAttributes

    private static final HashMap keysAttributes

  The allowed attributes in variable `attributes`.

### keysNoStroke

    private static final HashMap keysNoStroke

  The allowed attributes in variable `noStroke`.

### value

    protected String value

  The value of this object.

### encoding

    protected String encoding

  The encoding.

### font

    protected PdfFont font

  The font for this `PdfChunk`.

### baseFont

    protected BaseFont baseFont

### splitCharacter

    protected SplitCharacter splitCharacter

### attributes

    protected HashMap attributes

  Metric attributes.

  This attributes require the mesurement of characters widths when rendering such as underline.

### noStroke

    protected HashMap noStroke

  Non metric attributes.

  This attributes do not require the mesurement of characters widths when rendering such as Color.

### newlineSplit

    protected boolean newlineSplit

  `true` if the chunk split was cause by a newline.

### image

    protected Image image

  The image in this `PdfChunk`, if it has one

### offsetX

    protected float offsetX

  The offset in the x direction for the image

### offsetY

    protected float offsetY

  The offset in the y direction for the image

### changeLeading

    protected boolean changeLeading

  Indicates if the height and offset of the Image has to be taken into account

Constructor Detail

### PdfChunk

    PdfChunk(String string,
             PdfChunk other)

  Constructs a `PdfChunk`-object.

  Parameters:
    `string` - the content of the `PdfChunk`-object
    `other` - Chunk with the same style you want for the new Chunk

### PdfChunk

    PdfChunk(Chunk chunk,
             PdfAction action)

  Constructs a `PdfChunk`-object.

  Parameters:
    `chunk` - the original `Chunk`-object
    `action` - the `PdfAction` if the `Chunk` comes from an `Anchor`

Method Detail

### getUnicodeEquivalent

    public char getUnicodeEquivalent(char c)

  Gets the Unicode equivalent to a CID. The (inexistent) CID is translated as '\n'. It has only meaning with CJK fonts with Identity encoding.

  Parameters:
    `c` - the CID code
  Returns:
    the Unicode equivalent

### getWord

    protected int getWord(String text,
                          int start)

### split

    PdfChunk split(float width)

  Splits this `PdfChunk` if it's too long for the given width.

  Returns null if the `PdfChunk` wasn't truncated.

  Parameters:
    `width` - a given width
  Returns:
    the `PdfChunk` that doesn't fit into the width.

### truncate

    PdfChunk truncate(float width)

  Truncates this `PdfChunk` if it's too long for the given width.

  Returns null if the `PdfChunk` wasn't truncated.

  Parameters:
    `width` - a given width
  Returns:
    the `PdfChunk` that doesn't fit into the width.

### font

    PdfFont font()

  Returns the font of this `Chunk`.

  Returns:
    a `PdfFont`

### color

    Color color()

  Returns the color of this `Chunk`.

  Returns:
    a `Color`

### width

    float width()

  Returns the width of this `PdfChunk`.

  Returns:
    a width

### isNewlineSplit

    public boolean isNewlineSplit()

  Checks if the `PdfChunk` split was caused by a newline.

  Returns:
    `true` if the `PdfChunk` split was caused by a newline.

### getWidthCorrected

    public float getWidthCorrected(float charSpacing,
                                   float wordSpacing)

  Gets the width of the `PdfChunk` taking into account the extra character and word spacing.

  Parameters:
    `charSpacing` - the extra character spacing
    `wordSpacing` - the extra word spacing
  Returns:
    the calculated width

### getTextRise

    public float getTextRise()

  Gets the text displacement relatiev to the baseline.

  Returns:
    a displacement in points

### trimLastSpace

    public float trimLastSpace()

  Trims the last space.

  Returns:
    the width of the space trimmed, otherwise 0

### trimFirstSpace

    public float trimFirstSpace()

### getAttribute

    Object getAttribute(String name)

  Gets an attribute. The search is made in `attributes` and `noStroke`.

  Parameters:
    `name` - the attribute key
  Returns:
    the attribute value or null if not found

### isAttribute

    boolean isAttribute(String name)

  Checks if the attribute exists.

  Parameters:
    `name` - the attribute key
  Returns:
    `true` if the attribute exists

### isStroked

    boolean isStroked()

  Checks if this `PdfChunk` needs some special metrics handling.

  Returns:
    `true` if this `PdfChunk` needs some special metrics handling.

### isImage

    boolean isImage()

  Checks if there is an image in the `PdfChunk`.

  Returns:
    `true` if an image is present

### getImage

    Image getImage()

  Gets the image in the `PdfChunk`.

  Returns:
    the image or `null`

### setImageOffsetX

    void setImageOffsetX(float offsetX)

  Sets the image offset in the x direction

  Parameters:
    `offsetX` - the image offset in the x direction

### getImageOffsetX

    float getImageOffsetX()

  Gets the image offset in the x direction

  Returns:
    the image offset in the x direction

### setImageOffsetY

    void setImageOffsetY(float offsetY)

  Sets the image offset in the y direction

  Parameters:
    `offsetY` - the image offset in the y direction

### getImageOffsetY

    float getImageOffsetY()

  Gets the image offset in the y direction

  Returns:
    Gets the image offset in the y direction

### setValue

    void setValue(String value)

  sets the value.

  Parameters:
    `value` - content of the Chunk

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

### isSpecialEncoding

    boolean isSpecialEncoding()

  Tells you if this string is in Chinese, Japanese, Korean or Identity-H.

  Returns:
    true if the Chunk has a special encoding

### getEncoding

    String getEncoding()

  Gets the encoding of this string.

  Returns:
    a `String`

### length

    int length()

### isSplitCharacter

    public boolean isSplitCharacter(int start,
                                    int current,
                                    int end,
                                    char[] cc,
                                    PdfChunk[] ck)

  Checks if a character can be used to split a `PdfString`.

  for the moment every character less than or equal to SPACE and the character '-' are 'splitCharacters'.

  Specified by:
    `isSplitCharacter` in interface `SplitCharacter`
  Parameters:
    `start` - start position in the array
    `current` - current position in the array
    `end` - end position in the array
    `cc` - the character array that has to be checked
    `ck` - chunk array
  Returns:
    `true` if the character can be used to split a string, `false` otherwise

### isExtSplitCharacter

    boolean isExtSplitCharacter(int start,
                                int current,
                                int end,
                                char[] cc,
                                PdfChunk[] ck)

### trim

    String trim(String string)

  Removes all the ' ' and '-'-characters on the right of a `String`.

  Parameters:
    `string` - the `String`that has to be trimmed.``
  Returns:
    the trimmed `String`

### changeLeading

    public boolean changeLeading()

### getCharWidth

    float getCharWidth(char c)

### noPrint

    public static boolean noPrint(char c)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD