Class Chunk
java.lang.Object
com.lowagie.text.Chunk
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.Key for Action.Deprecated.Contains some of the attributes for this Chunk.static final StringDeprecated.Key for background.static final StringDeprecated.Key for character spacing.static final StringDeprecated.Key for color.protected StringBufferDeprecated.This is the content of this chunk of text.static final StringDeprecated.Key for encoding.protected FontDeprecated.This is theFontof this chunk of text.static final StringDeprecated.Key for generic tag.static final StringDeprecated.Key for text horizontal scaling.static final StringDeprecated.Key for hyphenation.static final StringDeprecated.Key for image.static final StringDeprecated.Key for local destination.static final StringDeprecated.Key for local goto.static final ChunkDeprecated.This is a Chunk containing a newline.static final StringDeprecated.Key for newpage.static final ChunkDeprecated.This is a Chunk containing a newpage.static final StringDeprecated.The character stand in for an image or a separator.static final StringDeprecated.Key for annotation.static final StringDeprecated.Key for remote goto.static final StringDeprecated.Key for drawInterface of the Separator.static final StringDeprecated.Key for text skewing.static final StringDeprecated.Key for split character.static final StringDeprecated.Key for sub/superscript.static final StringDeprecated.Key for drawInterface of the tab.static final StringDeprecated.Key for text rendering mode.static final StringDeprecated.Key for underline.Fields inherited from interface 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, FOOTNOTE, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MODIFICATIONDATE, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK -
Constructor Summary
ConstructorsConstructorDescriptionChunk()Deprecated.Empty constructor.Chunk(char c) Deprecated.Constructs a chunk of text with a char, without specifying aFont.Deprecated.Constructs a chunk of text with a char and a certainFont.Deprecated.AChunkcopy constructor.Deprecated.Constructs a chunk containing anImage.Deprecated.Constructs a chunk containing anImage.Chunk(DrawInterface separator) Deprecated.Creates a separator Chunk.Chunk(DrawInterface separator, boolean vertical) Deprecated.Creates a separator Chunk.Chunk(DrawInterface separator, float tabPosition) Deprecated.Creates a tab Chunk.Chunk(DrawInterface separator, float tabPosition, boolean newline) Deprecated.Creates a tab Chunk.Deprecated.Constructs a chunk of text with a certain content, without specifying aFont.Deprecated.Constructs a chunk of text with a certain content and a certainFont. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.appends some text to thisChunk.floatDeprecated.Gets the character spacing.Deprecated.Gets the attributes for thisChunk.Deprecated.Gets all the chunks in this element.Deprecated.Returns the content of thisChunk.getFont()Deprecated.Gets the font of thisChunk.floatDeprecated.Gets the horizontal scaling.Deprecated.Returns the hyphenation (if present).getImage()Deprecated.Returns the image.floatDeprecated.Gets the text displacement relative to the baseline.floatDeprecated.Gets the width of the Chunk in points.booleanDeprecated.Checks the attributes of thisChunk.booleanDeprecated.Checks if this element is a content object.booleanisEmpty()Deprecated.Checks is thisChunkis empty.booleanDeprecated.Checks if this element is nestable.booleanprocess(ElementListener listener) Deprecated.Processes the element by adding it (or the different parts) to anElementListener.Deprecated.Sets an action for thisChunk.Deprecated.Sets an anchor for thisChunk.Deprecated.Sets an anchor for thisChunk.setAnnotation(PdfAnnotation annotation) Deprecated.Sets a generic annotation to thisChunk.private ChunksetAttribute(String name, Object obj) Deprecated.Sets an arbitrary attribute.setBackground(Color color) Deprecated.Sets the color of the backgroundChunk.setBackground(Color color, float extraLeft, float extraBottom, float extraRight, float extraTop) Deprecated.Sets the color and the size of the backgroundChunk.setCharacterSpacing(float charSpace) Deprecated.Sets the character spacing.voidsetChunkAttributes(Map<String, Object> attributes) Deprecated.Sets the attributes all at once.voidDeprecated.Sets the font of thisChunk.setGenericTag(String text) Deprecated.Sets the generic tagChunk.setHorizontalScaling(float scale) Deprecated.Sets the text horizontal scaling.setHyphenation(HyphenationEvent hyphenation) Deprecated.sets the hyphenation engine to thisChunk.setLocalDestination(String name) Deprecated.Sets a local destination for thisChunk.setLocalGoto(String name) Deprecated.Sets a local goto for thisChunk.Deprecated.Sets a new page tag..setRemoteGoto(String filename, int page) Deprecated.Sets a goto for a remote destination for thisChunk.setRemoteGoto(String filename, String name) Deprecated.Sets a goto for a remote destination for thisChunk.setSkew(float alpha, float beta) Deprecated.Skews the text to simulate italic and other effects.setSplitCharacter(SplitCharacter splitCharacter) Deprecated.Sets the split characters.setTextRenderMode(int mode, float strokeWidth, Color strokeColor) Deprecated.Sets the text rendering mode.setTextRise(float rise) Deprecated.Sets the text displacement relative to the baseline.setUnderline(float thickness, float yPosition) Deprecated.Sets an horizontal line that can be an underline or a strikethrough.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.toString()Deprecated.Returns the content of thisChunk.inttype()Deprecated.Gets the type of the text element.
-
Field Details
-
OBJECT_REPLACEMENT_CHARACTER
Deprecated.The character stand in for an image or a separator.- See Also:
-
NEWLINE
-
NEXTPAGE
-
SEPARATOR
Deprecated.Key for drawInterface of the Separator.- Since:
- 2.1.2
- See Also:
-
TAB
-
HSCALE
-
UNDERLINE
-
SUBSUPSCRIPT
-
SKEW
-
BACKGROUND
-
TEXTRENDERMODE
-
SPLITCHARACTER
-
HYPHENATION
-
REMOTEGOTO
-
LOCALGOTO
-
LOCALDESTINATION
-
GENERICTAG
-
IMAGE
-
ACTION
-
NEWPAGE
-
PDFANNOTATION
-
COLOR
-
ENCODING
-
CHAR_SPACING
-
-
font
-
attributes
-
-
Constructor Details
-
Chunk
public Chunk()Deprecated.Empty constructor. -
Chunk
Deprecated.AChunkcopy constructor.- Parameters:
ck- theChunkto be copied
-
Chunk
-
Chunk
Deprecated.Constructs a chunk of text with a certain content, without specifying aFont.- Parameters:
content- the content
-
Chunk
Deprecated.Constructs a chunk of text with a char and a certainFont.- Parameters:
c- the contentfont- the font
-
Chunk
public Chunk(char c) Deprecated.Constructs a chunk of text with a char, without specifying aFont.- Parameters:
c- the content
-
Chunk
Deprecated.Constructs a chunk containing anImage.- Parameters:
image- the imageoffsetX- the image offset in the x directionoffsetY- the image offset in the y direction
-
Chunk
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
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
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
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
Deprecated.Constructs a chunk containing anImage.- Parameters:
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 image
-
-
Method Details
-
process
Deprecated.Processes the element by adding it (or the different parts) to anElementListener. -
type
-
getChunks
-
append
Deprecated.appends some text to thisChunk.- Parameters:
string-String- Returns:
- a
StringBuffer
-
getFont
-
setFont
-
getContent
-
toString
-
isEmpty
public boolean isEmpty()Deprecated.Checks is thisChunkis empty.- Returns:
falseif 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 thisChunk.- Returns:
- false if there aren't any.
-
getChunkAttributes
-
setChunkAttributes
-
setAttribute
-
getHorizontalScaling
public float getHorizontalScaling()Deprecated.Gets the horizontal scaling.- Returns:
- a percentage in float
-
setHorizontalScaling
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
Deprecated.Sets an horizontal line that can be an underline or a strikethrough. Actually, the line can be anywhere vertically and has always theChunkwidth. Multiple call to this method will produce multiple lines.- Parameters:
thickness- the absolute thickness of the lineyPosition- 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 theChunkwidth. Multiple call to this method will produce multiple lines.- Parameters:
color- the color of the line ornullto 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- Returns:
- this
Chunk
-
getTextRise
public float getTextRise()Deprecated.Gets the text displacement relative to the baseline.- Returns:
- a displacement in points
-
setTextRise
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
Deprecated.Skews the text to simulate italic and other effects. Tryalpha=0andbeta=12.- Parameters:
alpha- the first angle in degreesbeta- the second angle in degrees- Returns:
- this
Chunk
-
setBackground
-
setBackground
public Chunk setBackground(Color color, float extraLeft, float extraBottom, float extraRight, float extraTop) Deprecated.Sets the color and the size of the backgroundChunk.- Parameters:
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- Returns:
- this
Chunk
-
setTextRenderMode
Deprecated.Sets the text rendering mode. It can outline text, simulate bold and make text invisible.- Parameters:
mode- the text rendering mode. It can bePdfContentByte.TEXT_RENDER_MODE_FILL,PdfContentByte.TEXT_RENDER_MODE_STROKE,PdfContentByte.TEXT_RENDER_MODE_FILL_STROKEandPdfContentByte.TEXT_RENDER_MODE_INVISIBLE.strokeWidth- the stroke line width for the modesPdfContentByte.TEXT_RENDER_MODE_STROKEandPdfContentByte.TEXT_RENDER_MODE_FILL_STROKE.strokeColor- the stroke color ornullto follow the text color- Returns:
- this
Chunk
-
setSplitCharacter
Deprecated.Sets the split characters.- Parameters:
splitCharacter- theSplitCharacterinterface- Returns:
- this
Chunk
-
setRemoteGoto
-
setRemoteGoto
-
setLocalGoto
-
setLocalDestination
-
setGenericTag
-
getImage
-
setAction
-
setAnchor
-
setAnchor
-
setNewPage
-
setAnnotation
Deprecated.Sets a generic annotation to thisChunk.- Parameters:
annotation- the annotation- Returns:
- this
Chunk
-
isContent
public boolean isContent()Deprecated.Description copied from interface:ElementChecks if this element is a content object. If not, it's a metadata object. -
isNestable
public boolean isNestable()Deprecated.Description copied from interface:ElementChecks if this element is nestable.- Specified by:
isNestablein interfaceElement- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
-
getHyphenation
Deprecated.Returns the hyphenation (if present).- Returns:
- an object of
HyphenationEvent - Since:
- 2.1.2
-
setHyphenation
Deprecated.sets the hyphenation engine to thisChunk.- Parameters:
hyphenation- the hyphenation engine- Returns:
- this
Chunk
-
getCharacterSpacing
public float getCharacterSpacing()Deprecated.Gets the character spacing.- Returns:
- a value in float
-
setCharacterSpacing
Deprecated.Sets the character spacing.- Parameters:
charSpace- the character spacing value- Returns:
- this
Chunk
-