|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.lowagie.text.Chunk
public class Chunk
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 Summary | |
|---|---|
static String |
ACTION
Key for Action. |
protected HashMap |
attributes
Contains some of the attributes for this Chunk. |
static String |
BACKGROUND
Key for background. |
static String |
COLOR
Key for color. |
protected StringBuffer |
content
This is the content of this chunk of text. |
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. |
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. |
| Fields inherited from interface com.lowagie.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, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE |
| Constructor Summary | |
|---|---|
Chunk()
Empty constructor. |
|
Chunk(char c)
Constructs a chunk of text with a char, without specifying a Font
. |
|
Chunk(char c,
Font font)
Constructs a chunk of text with a char and a certain Font. |
|
Chunk(Chunk ck)
A Chunk copy constructor. |
|
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)
Deprecated. As of iText 2.0.3, use ElementFactory.getChunk(Properties) instead,
scheduled for removal at 2.1.0 |
|
Chunk(String content)
Constructs a chunk of text with a certain content, without specifying a Font. |
|
Chunk(String content,
Font font)
Constructs a chunk of text with a certain content and a certain
Font. |
|
| Method Summary | |
|---|---|
static Object[][] |
addToArray(Object[][] original,
Object[] item)
Deprecated. As of iText 2.0.3, replaced by Utilities.addToArray(Object[][],Object[]),
scheduled for removal at 2.1.0 |
StringBuffer |
append(String string)
appends some text to this Chunk. |
String |
content()
Deprecated. As of iText 2.0.3, replaced by getContent(),
scheduled for removal at 2.1.0 |
Font |
font()
Deprecated. As of iText 2.0.3, replaced by getFont(),
scheduled for removal at 2.1.0 |
HashMap |
getAttributes()
Gets the attributes for this Chunk. |
ArrayList |
getChunks()
Gets all the chunks in this element. |
String |
getContent()
Returns the content of this Chunk. |
Font |
getFont()
Gets the font of this Chunk. |
float |
getHorizontalScaling()
Gets the horizontal scaling. |
Image |
getImage()
Returns the image. |
static Set |
getKeySet(Hashtable table)
Deprecated. As of iText 2.0.3, replaced by Utilities.getKeySet(Hashtable),
scheduled for removal at 2.1.0 |
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 |
isContent()
Checks if this element is a content object. |
boolean |
isEmpty()
Checks is this Chunk is empty. |
boolean |
isNestable()
Checks if this element is nestable. |
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(String url)
Sets an anchor for this Chunk. |
Chunk |
setAnchor(URL url)
Sets an anchor for this Chunk. |
Chunk |
setAnnotation(PdfAnnotation annotation)
Sets a generic annotation to this Chunk. |
private Chunk |
setAttribute(String name,
Object obj)
Sets an arbitrary attribute. |
void |
setAttributes(HashMap attributes)
Sets the attributes all at once. |
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,
int page)
Sets a goto for a remote destination for this Chunk. |
Chunk |
setRemoteGoto(String filename,
String name)
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(Color color,
float thickness,
float thicknessMul,
float yPosition,
float yPositionMul,
int cap)
Sets an horizontal line that can be an underline or a strikethrough. |
Chunk |
setUnderline(float thickness,
float yPosition)
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String OBJECT_REPLACEMENT_CHARACTER
public static final Chunk NEWLINE
public static final Chunk NEXTPAGE
protected StringBuffer content
protected Font font
Font of this chunk of text.
protected HashMap attributes
public static final String HSCALE
public static final String UNDERLINE
public static final String SUBSUPSCRIPT
public static final String SKEW
public static final String BACKGROUND
public static final String TEXTRENDERMODE
public static final String SPLITCHARACTER
public static final String HYPHENATION
public static final String REMOTEGOTO
public static final String LOCALGOTO
public static final String LOCALDESTINATION
public static final String GENERICTAG
public static final String IMAGE
public static final String ACTION
public static final String NEWPAGE
public static final String PDFANNOTATION
public static final String COLOR
public static final String ENCODING
| Constructor Detail |
|---|
public Chunk()
public Chunk(Chunk ck)
Chunk copy constructor.
ck - the Chunk to be copied
public Chunk(String content,
Font font)
Font.
content - the contentfont - the fontpublic Chunk(String content)
Font.
content - the content
public Chunk(char c,
Font font)
Font.
c - the contentfont - the fontpublic Chunk(char c)
Font
.
c - the content
public Chunk(Image image,
float offsetX,
float offsetY)
Image.
image - the imageoffsetX - the image offset in the x directionoffsetY - the image offset in the y direction
public Chunk(Image image,
float offsetX,
float offsetY,
boolean changeLeading)
Image.
image - the imageoffsetX - the image offset in the x directionoffsetY - the image offset in the y directionchangeLeading - true if the leading has to be adapted to the imagepublic Chunk(Properties attributes)
ElementFactory.getChunk(Properties) instead,
scheduled for removal at 2.1.0
Chunk that has been constructed taking in
account the value of some attributes .
attributes - Some attributes| Method Detail |
|---|
public boolean process(ElementListener listener)
ElementListener.
process in interface Elementlistener - an ElementListener
true if the element was processed successfullypublic int type()
type in interface Elementpublic ArrayList getChunks()
getChunks in interface ElementArrayListpublic StringBuffer append(String string)
Chunk.
string - String
StringBufferpublic void setFont(Font font)
Chunk.
font - a Fontpublic Font getFont()
Chunk.
Fontpublic String getContent()
Chunk.
Stringpublic String toString()
Chunk.
toString in interface ElementtoString in class ObjectStringpublic boolean isEmpty()
Chunk is empty.
false if the Chunk contains other characters than
space.public float getWidthPoint()
public boolean hasAttributes()
Chunk.
public HashMap getAttributes()
Chunk.
It may be null.
Chunkpublic void setAttributes(HashMap attributes)
attributes - the attributes of a Chunk
private Chunk setAttribute(String name,
Object obj)
name - the key for the attributeobj - the value of the attribute
Chunkpublic Chunk setHorizontalScaling(float scale)
scale - the horizontal scaling factor
Chunkpublic float getHorizontalScaling()
public Chunk setUnderline(float thickness,
float yPosition)
Chunk width. Multiple call to this method will produce multiple
lines.
thickness - the absolute thickness of the lineyPosition - the absolute y position relative to the baseline
Chunk
public Chunk setUnderline(Color color,
float thickness,
float thicknessMul,
float yPosition,
float yPositionMul,
int cap)
Chunk width. Multiple call to this method will produce multiple
lines.
color - the color of the line or null to follow the
text colorthickness - the absolute thickness of the linethicknessMul - the thickness multiplication factor with the font sizeyPosition - the absolute y position relative to the baselineyPositionMul - the position multiplication factor with the font sizecap - the end line cap. Allowed values are
PdfContentByte.LINE_CAP_BUTT, PdfContentByte.LINE_CAP_ROUND
and PdfContentByte.LINE_CAP_PROJECTING_SQUARE
Chunkpublic Chunk setTextRise(float rise)
It can be used to implement sub/superscript.
rise - the displacement in points
Chunkpublic float getTextRise()
public Chunk setSkew(float alpha,
float beta)
alpha=0
and beta=12.
alpha - the first angle in degreesbeta - the second angle in degrees
Chunkpublic Chunk setBackground(Color color)
Chunk.
color - the color of the background
Chunk
public Chunk setBackground(Color color,
float extraLeft,
float extraBottom,
float extraRight,
float extraTop)
Chunk.
color - the color of the backgroundextraLeft - increase the size of the rectangle in the leftextraBottom - increase the size of the rectangle in the bottomextraRight - increase the size of the rectangle in the rightextraTop - increase the size of the rectangle in the top
Chunk
public Chunk setTextRenderMode(int mode,
float strokeWidth,
Color strokeColor)
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
Chunkpublic Chunk setSplitCharacter(SplitCharacter splitCharacter)
splitCharacter - the SplitCharacter interface
Chunkpublic Chunk setHyphenation(HyphenationEvent hyphenation)
Chunk.
hyphenation - the hyphenation engine
Chunk
public Chunk setRemoteGoto(String filename,
String name)
Chunk.
filename - the file name of the destination documentname - the name of the destination to go to
Chunk
public Chunk setRemoteGoto(String filename,
int page)
Chunk.
filename - the file name of the destination documentpage - the page of the destination to go to. First page is 1
Chunkpublic Chunk setLocalGoto(String name)
Chunk.
There must be a local destination matching the name.
name - the name of the destination to go to
Chunkpublic Chunk setLocalDestination(String name)
Chunk.
name - the name for this destination
Chunkpublic Chunk setGenericTag(String text)
Chunk.
The text for this tag can be retrieved with PdfPageEvent.
text - the text for the tag
Chunkpublic Image getImage()
public Chunk setAction(PdfAction action)
Chunk.
action - the action
Chunkpublic Chunk setAnchor(URL url)
Chunk.
url - the URL to link to
Chunkpublic Chunk setAnchor(String url)
Chunk.
url - the url to link to
Chunkpublic Chunk setNewPage()
Chunkpublic Chunk setAnnotation(PdfAnnotation annotation)
Chunk.
annotation - the annotation
Chunkpublic boolean isContent()
Element
isContent in interface ElementElement.isContent()public boolean isNestable()
Element
isNestable in interface ElementElement.isNestable()public String content()
getContent(),
scheduled for removal at 2.1.0
Chunk.
Stringpublic Font font()
getFont(),
scheduled for removal at 2.1.0
Chunk.
Fontpublic static Set getKeySet(Hashtable table)
Utilities.getKeySet(Hashtable),
scheduled for removal at 2.1.0
table - a Hashtable
public static Object[][] addToArray(Object[][] original,
Object[] item)
Utilities.addToArray(Object[][],Object[]),
scheduled for removal at 2.1.0
original - the original array or nullitem - the item to be added to the array
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||