Package com.itextpdf.text.pdf
Class PdfChunk
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfChunk
-
-
Field Summary
Fields Modifier and Type Field Description protected IAccessibleElement
accessibleElement
protected java.util.HashMap<java.lang.String,java.lang.Object>
attributes
Metric attributes.protected BaseFont
baseFont
protected boolean
changeLeading
Indicates if the height and offset of the Image has to be taken into accountprotected java.lang.String
encoding
The encoding.protected PdfFont
font
The font for thisPdfChunk
.protected Image
image
The image in thisPdfChunk
, if it has oneprotected float
imageScalePercentage
private static float
ITALIC_ANGLE
private static java.util.HashSet<java.lang.String>
keysAttributes
The allowed attributes in variableattributes
.private static java.util.HashSet<java.lang.String>
keysNoStroke
The allowed attributes in variablenoStroke
.protected float
leading
The leading that can overrule the existing leading.protected boolean
newlineSplit
true
if the chunk split was cause by a newline.protected java.util.HashMap<java.lang.String,java.lang.Object>
noStroke
Non metric attributes.protected float
offsetX
The offset in the x direction for the imageprotected float
offsetY
The offset in the y direction for the imageprivate static char[]
singleSpace
protected SplitCharacter
splitCharacter
private static java.lang.String
TABSTOP
static float
UNDERLINE_OFFSET
static float
UNDERLINE_THICKNESS
protected java.lang.String
value
The value of this object.
-
Constructor Summary
Constructors Constructor Description PdfChunk(Chunk chunk, PdfAction action)
Constructs aPdfChunk
-object.PdfChunk(Chunk chunk, PdfAction action, TabSettings tabSettings)
Constructs aPdfChunk
-object.PdfChunk(java.lang.String string, PdfChunk other)
Constructs aPdfChunk
-object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) void
adjustLeft(float newValue)
Deprecated.boolean
changeLeading()
(package private) BaseColor
color()
Returns the color of thisChunk
.(package private) PdfFont
font()
Returns the font of thisChunk
.(package private) java.lang.Object
getAttribute(java.lang.String name)
Gets an attribute.(package private) float
getCharWidth(int c)
(package private) java.lang.String
getEncoding()
Gets the encoding of this string.(package private) Image
getImage()
Gets the image in thePdfChunk
.(package private) float
getImageHeight()
(package private) float
getImageOffsetX()
Gets the image offset in the x direction(package private) float
getImageOffsetY()
Gets the image offset in the y directionfloat
getImageScalePercentage()
Returns a scalePercentage in case the image needs to be scaled.(package private) float
getImageWidth()
float
getLeading()
(package private) TabStop
getTabStop()
(package private) static TabStop
getTabStop(PdfChunk tab, float tabPosition)
float
getTextRise()
Gets the text displacement relative to the baseline.int
getUnicodeEquivalent(int c)
Gets the Unicode equivalent to a CID.float
getWidthCorrected(float charSpacing, float wordSpacing)
Gets the width of thePdfChunk
taking into account the extra character and word spacing.protected int
getWord(java.lang.String text, int start)
(package private) float
height()
(package private) boolean
isAttribute(java.lang.String name)
Checks if the attribute exists.(package private) boolean
isExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
(package private) boolean
isHorizontalSeparator()
Checks if thisPdfChunk
is a horizontal Separator Chunk.(package private) boolean
isImage()
Checks if there is an image in thePdfChunk
.boolean
isNewlineSplit()
Checks if thePdfChunk
split was caused by a newline.(package private) boolean
isSeparator()
Checks if thisPdfChunk
is a Separator Chunk.(package private) boolean
isSpecialEncoding()
Tells you if this string is in Chinese, Japanese, Korean or Identity-H.(package private) boolean
isStroked()
Checks if thisPdfChunk
needs some special metrics handling.(package private) boolean
isTab()
Checks if thisPdfChunk
is a tab Chunk.(package private) int
length()
(package private) int
lengthUtf32()
static boolean
noPrint(int 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 directionvoid
setImageScalePercentage(float imageScalePercentage)
Sets a scale percentage in case the image needs to be scaled.(package private) void
setTabStop(TabStop tabStop)
(package private) void
setValue(java.lang.String value)
sets the value.(package private) PdfChunk
split(float width)
Splits thisPdfChunk
if it's too long for the given width.java.lang.String
toString()
(package private) java.lang.String
trim(java.lang.String string)
Removes all the ' ' and '-'-characters on the right of aString
.float
trimFirstSpace()
float
trimLastSpace()
Trims the last space.(package private) PdfChunk
truncate(float width)
Truncates thisPdfChunk
if it's too long for the given width.(package private) float
width()
Returns the width of thisPdfChunk
.(package private) float
width(java.lang.String str)
-
-
-
Field Detail
-
singleSpace
private static final char[] singleSpace
-
ITALIC_ANGLE
private static final float ITALIC_ANGLE
- See Also:
- Constant Field Values
-
keysAttributes
private static final java.util.HashSet<java.lang.String> keysAttributes
The allowed attributes in variableattributes
.
-
keysNoStroke
private static final java.util.HashSet<java.lang.String> keysNoStroke
The allowed attributes in variablenoStroke
.
-
TABSTOP
private static final java.lang.String TABSTOP
- See Also:
- Constant Field Values
-
value
protected java.lang.String value
The value of this object.
-
encoding
protected java.lang.String encoding
The encoding.
-
font
protected PdfFont font
The font for thisPdfChunk
.
-
baseFont
protected BaseFont baseFont
-
splitCharacter
protected SplitCharacter splitCharacter
-
attributes
protected java.util.HashMap<java.lang.String,java.lang.Object> attributes
Metric attributes.This attributes require the measurement of characters widths when rendering such as underline.
-
noStroke
protected java.util.HashMap<java.lang.String,java.lang.Object> noStroke
Non metric attributes.This attributes do not require the measurement of characters widths when rendering such as BaseColor.
-
newlineSplit
protected boolean newlineSplit
true
if the chunk split was cause by a newline.
-
image
protected Image image
The image in thisPdfChunk
, if it has one
-
imageScalePercentage
protected float imageScalePercentage
-
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
-
leading
protected float leading
The leading that can overrule the existing leading.
-
accessibleElement
protected IAccessibleElement accessibleElement
-
UNDERLINE_THICKNESS
public static final float UNDERLINE_THICKNESS
- See Also:
- Constant Field Values
-
UNDERLINE_OFFSET
public static final float UNDERLINE_OFFSET
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PdfChunk
PdfChunk(java.lang.String string, PdfChunk other)
Constructs aPdfChunk
-object.- Parameters:
string
- the content of thePdfChunk
-objectother
- Chunk with the same style you want for the new Chunk
-
PdfChunk
PdfChunk(Chunk chunk, PdfAction action)
Constructs aPdfChunk
-object.- Parameters:
chunk
- the originalChunk
-objectaction
- thePdfAction
if theChunk
comes from anAnchor
-
PdfChunk
PdfChunk(Chunk chunk, PdfAction action, TabSettings tabSettings)
Constructs aPdfChunk
-object.- Parameters:
chunk
- the originalChunk
-objectaction
- thePdfAction
if theChunk
comes from anAnchor
tabSettings
- the Phrase tab settings
-
-
Method Detail
-
getUnicodeEquivalent
public int getUnicodeEquivalent(int c)
Gets the Unicode equivalent to a CID. The (inexistent) CIDis 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(java.lang.String text, int start)
-
split
PdfChunk split(float width)
Splits thisPdfChunk
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 thisPdfChunk
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 thisChunk
.- Returns:
- a
PdfFont
-
color
BaseColor color()
Returns the color of thisChunk
.- Returns:
- a
BaseColor
-
width
float width()
Returns the width of thisPdfChunk
.- Returns:
- a width
-
width
float width(java.lang.String str)
-
height
float height()
-
isNewlineSplit
public boolean isNewlineSplit()
Checks if thePdfChunk
split was caused by a newline.- Returns:
true
if thePdfChunk
split was caused by a newline.
-
getWidthCorrected
public float getWidthCorrected(float charSpacing, float wordSpacing)
Gets the width of thePdfChunk
taking into account the extra character and word spacing.- Parameters:
charSpacing
- the extra character spacingwordSpacing
- the extra word spacing- Returns:
- the calculated width
-
getTextRise
public float getTextRise()
Gets the text displacement relative 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
java.lang.Object getAttribute(java.lang.String name)
Gets an attribute. The search is made inattributes
andnoStroke
.- Parameters:
name
- the attribute key- Returns:
- the attribute value or null if not found
-
isAttribute
boolean isAttribute(java.lang.String name)
Checks if the attribute exists.- Parameters:
name
- the attribute key- Returns:
true
if the attribute exists
-
isStroked
boolean isStroked()
Checks if thisPdfChunk
needs some special metrics handling.- Returns:
true
if thisPdfChunk
needs some special metrics handling.
-
isSeparator
boolean isSeparator()
Checks if thisPdfChunk
is a Separator Chunk.- Returns:
- true if this chunk is a separator.
- Since:
- 2.1.2
-
isHorizontalSeparator
boolean isHorizontalSeparator()
Checks if thisPdfChunk
is a horizontal Separator Chunk.- Returns:
- true if this chunk is a horizontal separator.
- Since:
- 2.1.2
-
isTab
boolean isTab()
Checks if thisPdfChunk
is a tab Chunk.- Returns:
- true if this chunk is a separator.
- Since:
- 2.1.2
-
adjustLeft
@Deprecated void adjustLeft(float newValue)
Deprecated.Correction for the tab position based on the left starting position.- Parameters:
newValue
- the new value for the left X.- Since:
- 2.1.2
-
getTabStop
TabStop getTabStop()
-
setTabStop
void setTabStop(TabStop tabStop)
-
isImage
boolean isImage()
Checks if there is an image in thePdfChunk
.- Returns:
true
if an image is present
-
getImage
Image getImage()
Gets the image in thePdfChunk
.- Returns:
- the image or
null
-
getImageHeight
float getImageHeight()
-
getImageWidth
float getImageWidth()
-
getImageScalePercentage
public float getImageScalePercentage()
Returns a scalePercentage in case the image needs to be scaled.- Returns:
- the imageScalePercentage
-
setImageScalePercentage
public void setImageScalePercentage(float imageScalePercentage)
Sets a scale percentage in case the image needs to be scaled.- Parameters:
imageScalePercentage
- the imageScalePercentage to set
-
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(java.lang.String value)
sets the value.- Parameters:
value
- content of the Chunk
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.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
java.lang.String getEncoding()
Gets the encoding of this string.- Returns:
- a
String
-
length
int length()
-
lengthUtf32
int lengthUtf32()
-
isExtSplitCharacter
boolean isExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
-
trim
java.lang.String trim(java.lang.String string)
Removes all the ' ' and '-'-characters on the right of aString
.- Parameters:
string
- theString
that has to be trimmed.
- Returns:
- the trimmed
String
-
changeLeading
public boolean changeLeading()
-
getLeading
public float getLeading()
-
getCharWidth
float getCharWidth(int c)
-
noPrint
public static boolean noPrint(int c)
-
-