com.lowagie.text
public class Chunk extends Object implements Element
Most elements can be divided in one or more Chunk
s. 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 Summary | |
---|---|
static String | ACTION Key for Action. |
protected HashMap | attributes Contains some of the attributes for this Chunk. |
static String | BACKGROUND Key for background. |
protected StringBuffer | content This is the content of this chunk of text. |
static String | COLOR Key for color. |
static String | ENCODING Key for encoding. |
protected Font | font This is the Font of this chunk of text. |
static String | GENERICTAG Key for generic tag. |
static String | HSCALE Key for text horizontal scaling. |
static String | HYPHENATION Key for hyphenation. |
static String | IMAGE Key for image. |
static String | LOCALDESTINATION Key for local destination. |
static String | LOCALGOTO Key for local goto. |
protected Properties | markupAttributes Contains extra markupAttributes |
static Chunk | NEWLINE This is a Chunk containing a newline. |
static String | NEWPAGE Key for newpage. |
static Chunk | NEXTPAGE This is a Chunk containing a newpage. |
static String | OBJECT_REPLACEMENT_CHARACTER
The character stand in for an image. |
static String | PDFANNOTATION Key for annotation. |
static String | REMOTEGOTO Key for remote goto. |
static String | SKEW Key for text skewing. |
static String | SPLITCHARACTER Key for split character. |
static String | SUBSUPSCRIPT Key for sub/superscript. |
static String | TEXTRENDERMODE Key for text rendering mode. |
static String | UNDERLINE Key for underline. |
Constructor Summary | |
---|---|
protected | Chunk()
Empty constructor. |
Chunk(Chunk ck)
A Chunk copy constructor. | |
Chunk(String content, Font font)
Constructs a chunk of text with a certain content and a certain
Font .
| |
Chunk(String content)
Constructs a chunk of text with a certain content, without specifying a
Font .
| |
Chunk(char c, Font font)
Constructs a chunk of text with a char and a certain Font .
| |
Chunk(char c)
Constructs a chunk of text with a char, without specifying a Font
.
| |
Chunk(Image image, float offsetX, float offsetY)
Constructs a chunk containing an Image .
| |
Chunk(Image image, float offsetX, float offsetY, boolean changeLeading)
Constructs a chunk containing an Image .
| |
Chunk(Properties attributes)
Returns a Chunk that has been constructed taking in
account the value of some attributes .
|
Method Summary | |
---|---|
static Object[][] | addToArray(Object[][] original, Object[] item)
Utility method to extend an array.
|
StringBuffer | append(String string)
appends some text to this Chunk .
|
String | content()
Returns the content of this Chunk .
|
Font | font()
Gets the font of this Chunk .
|
HashMap | getAttributes()
Gets the attributes for this Chunk .
|
ArrayList | getChunks()
Gets all the chunks in this element.
|
float | getHorizontalScaling()
Gets the horizontal scaling.
|
Image | getImage()
Returns the image.
|
static Set | getKeySet(Hashtable table)
Gets the keys of a Hashtable
|
float | getTextRise()
Gets the text displacement relatiev to the baseline.
|
float | getWidthPoint()
Gets the width of the Chunk in points.
|
boolean | hasAttributes()
Checks the attributes of this Chunk .
|
boolean | isEmpty()
Checks is this Chunk is empty.
|
static boolean | isTag(String tag)
Checks if a given tag corresponds with this object.
|
boolean | process(ElementListener listener)
Processes the element by adding it (or the different parts) to an
ElementListener .
|
Chunk | setAction(PdfAction action)
Sets an action for this Chunk .
|
Chunk | setAnchor(URL url)
Sets an anchor for this Chunk .
|
Chunk | setAnchor(String url)
Sets an anchor for this Chunk .
|
Chunk | setAnnotation(PdfAnnotation annotation)
Sets a generic annotation to this Chunk .
|
Chunk | setAttribute(String name, Object obj)
Sets an arbitrary attribute.
|
Chunk | setBackground(Color color)
Sets the color of the background Chunk .
|
Chunk | setBackground(Color color, float extraLeft, float extraBottom, float extraRight, float extraTop)
Sets the color and the size of the background Chunk .
|
void | setFont(Font font)
Sets the font of this Chunk .
|
Chunk | setGenericTag(String text)
Sets the generic tag Chunk .
|
Chunk | setHorizontalScaling(float scale)
Sets the text horizontal scaling. |
Chunk | setHyphenation(HyphenationEvent hyphenation)
sets the hyphenation engine to this Chunk .
|
Chunk | setLocalDestination(String name)
Sets a local destination for this Chunk .
|
Chunk | setLocalGoto(String name)
Sets a local goto for this Chunk .
|
Chunk | setNewPage()
Sets a new page tag..
|
Chunk | setRemoteGoto(String filename, String name)
Sets a goto for a remote destination for this Chunk .
|
Chunk | setRemoteGoto(String filename, int page)
Sets a goto for a remote destination for this Chunk .
|
Chunk | setSkew(float alpha, float beta)
Skews the text to simulate italic and other effects. |
Chunk | setSplitCharacter(SplitCharacter splitCharacter)
Sets the split characters.
|
Chunk | setTextRenderMode(int mode, float strokeWidth, Color strokeColor)
Sets the text rendering mode. |
Chunk | setTextRise(float rise)
Sets the text displacement relative to the baseline. |
Chunk | setUnderline(float thickness, float yPosition)
Sets an horizontal line that can be an underline or a strikethrough.
|
Chunk | setUnderline(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int cap)
Sets an horizontal line that can be an underline or a strikethrough.
|
String | toString()
Returns the content of this Chunk .
|
int | type()
Gets the type of the text element.
|
Font
of this chunk of text.Chunk
copy constructor.Parameters: ck the Chunk
to be copied
Font
.
Parameters: content the content font the font
Font
.
Parameters: content the content
Font
.
Parameters: c the content font the font
Font
.
Parameters: c the content
Image
.
Parameters: image the image offsetX the image offset in the x direction offsetY the image offset in the y direction
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
Chunk
that has been constructed taking in
account the value of some attributes .
Parameters: attributes Some attributes
Parameters: original
the original array or null
item
the item to be added to the array
Returns: a new array with the item appended
Chunk
.
Parameters: string
String
Returns: a StringBuffer
Chunk
.
Returns: a String
Chunk
.
Returns: a Font
Chunk
.
It may be null.
Returns: the attributes for this Chunk
Returns: an ArrayList
Returns: a percentage in float
Returns: the image
Parameters: table a Hashtable
Returns: the keyset of a Hashtable (or an empty set if table is null)
Returns: a displacement in points
Returns: a width in points
Chunk
.
Returns: false if there aren't any.
Chunk
is empty.
Returns: false
if the Chunk contains other characters than
space.
Parameters: tag the given tag
Returns: true if the tag corresponds
ElementListener
.
Parameters: listener
an ElementListener
Returns: true
if the element was processed successfully
Chunk
.
Parameters: action the action
Returns: this Chunk
Chunk
.
Parameters: url
the URL
to link to
Returns: this Chunk
Chunk
.
Parameters: url the url to link to
Returns: this Chunk
Chunk
.
Parameters: annotation the annotation
Returns: this Chunk
Parameters: name the key for the attribute obj the value of the attribute
Returns: this Chunk
Chunk
.
Parameters: color the color of the background
Returns: this Chunk
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
Chunk
.
Parameters: font
a Font
Chunk
.
The text for this tag can be retrieved with PdfPageEvent
.
Parameters: text the text for the tag
Returns: this Chunk
Parameters: scale the horizontal scaling factor
Returns: this Chunk
Chunk
.
Parameters: hyphenation the hyphenation engine
Returns: this Chunk
Chunk
.
Parameters: name the name for this destination
Returns: this Chunk
Chunk
.
There must be a local destination matching the name.
Parameters: name the name of the destination to go to
Returns: this Chunk
Returns: this Chunk
Chunk
.
Parameters: filename the file name of the destination document name the name of the destination to go to
Returns: this Chunk
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
alpha=0
and beta=12
.
Parameters: alpha the first angle in degrees beta the second angle in degrees
Returns: this Chunk
Parameters: splitCharacter
the SplitCharacter
interface
Returns: this Chunk
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
It can be used to implement sub/superscript.
Parameters: rise the displacement in points
Returns: this Chunk
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
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
Chunk
.
Returns: a String
Returns: a type